Added graylog-plugin-function-strlen
This commit is contained in:
parent
f32fa86998
commit
960e38039e
|
|
@ -0,0 +1,10 @@
|
|||
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
|
||||
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Getting started with your new Graylog plugin
|
||||
============================================
|
||||
|
||||
Welcome to your new Graylog plugin!
|
||||
|
||||
Please refer to https://docs.graylog.org/docs/plugins for documentation on how to write
|
||||
plugins for Graylog.
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
# StringLengthFunction Plugin for Graylog
|
||||
|
||||
__Use this paragraph to enter a description of your plugin.__
|
||||
|
||||
**Required Graylog version:** 2.0 and later
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
[Download the plugin](https://github.com/vshulkin/graylog-plugin-function-strlen/releases)
|
||||
and place the `.jar` file in your Graylog plugin directory. The plugin directory
|
||||
is the `plugins/` folder relative from your `graylog-server` directory by default
|
||||
and can be configured in your `graylog.conf` file.
|
||||
|
||||
Restart `graylog-server` and you are done.
|
||||
|
||||
Development
|
||||
-----------
|
||||
|
||||
You can improve your development experience for the web interface part of your plugin
|
||||
dramatically by making use of hot reloading. To do this, do the following:
|
||||
|
||||
* `git clone https://github.com/Graylog2/graylog2-server.git`
|
||||
* `cd graylog2-server/graylog2-web-interface`
|
||||
* `ln -s $YOURPLUGIN plugin/`
|
||||
* `npm install && npm start`
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
__Use this paragraph to document the usage of your plugin__
|
||||
|
||||
|
||||
Getting started
|
||||
---------------
|
||||
|
||||
This project is using Maven 3 and requires Java 8 or higher.
|
||||
|
||||
* Clone this repository.
|
||||
* Run `mvn package` to build a JAR file.
|
||||
* Optional: Run `mvn jdeb:jdeb` and `mvn rpm:rpm` to create a DEB and RPM package respectively.
|
||||
* Copy generated JAR file in target directory to your Graylog plugin directory.
|
||||
* Restart the Graylog.
|
||||
|
||||
Plugin Release
|
||||
--------------
|
||||
|
||||
We are using the maven release plugin:
|
||||
|
||||
```
|
||||
$ mvn release:prepare
|
||||
[...]
|
||||
$ mvn release:perform
|
||||
```
|
||||
|
||||
This sets the version numbers, creates a tag and pushes to GitHub.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
mvn license:format
|
||||
mvn install -Denforcer.skip=true
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
* as published by MongoDB, Inc.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* Server Side Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the Server Side Public License
|
||||
* along with this program. If not, see
|
||||
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
||||
*/
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
// Make sure that this is the correct path to the web interface part of the Graylog server repository.
|
||||
web_src_path: path.resolve(__dirname, '../graylog2-server', 'graylog2-web-interface'),
|
||||
};
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Your Company
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "StringLengthFunction",
|
||||
"version": "1.0.0-SNAPSHOT",
|
||||
"description": "",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "vshulkin/graylog-plugin-function-strlen"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"lint": "eslint src",
|
||||
"lint:path": "eslint",
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [
|
||||
"graylog"
|
||||
],
|
||||
"author": "John Doe <you@example.org>",
|
||||
"license": "MIT",
|
||||
"eslintConfig": {
|
||||
"extends": "graylog"
|
||||
},
|
||||
"dependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"graylog-web-plugin": "file:../graylog2-server/graylog2-web-interface/packages/graylog-web-plugin"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,242 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (C) 2020 Graylog, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the Server Side Public License, version 1,
|
||||
as published by MongoDB, Inc.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
Server Side Public License for more details.
|
||||
|
||||
You should have received a copy of the Server Side Public License
|
||||
along with this program. If not, see
|
||||
<http://www.mongodb.com/licensing/server-side-public-license>.
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.graylog.plugins</groupId>
|
||||
<artifactId>graylog-plugin-parent</artifactId>
|
||||
<version>5.1.5</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.example.plugins</groupId>
|
||||
<artifactId>graylog-plugin-function-strlen</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>Graylog ${project.artifactId} plugin.</description>
|
||||
<url>https://www.graylog.org</url>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>John Doe</name>
|
||||
<email>you@example.org</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:vshulkin/graylog-plugin-function-strlen.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:vshulkin/graylog-plugin-function-strlen.git</developerConnection>
|
||||
<url>https://github.com/vshulkin/graylog-plugin-function-strlen</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
|
||||
<!-- Plugins will not be deployed by default - set to `false` if you actually want to deploy it -->
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
|
||||
<graylog.version>${project.parent.version}</graylog.version>
|
||||
<graylog.plugin-dir>/usr/share/graylog-server/plugin</graylog.plugin-dir>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<name>Sonatype Nexus Snapshots</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>sonatype-nexus-staging</id>
|
||||
<name>Nexus Release Repository</name>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<repositories>
|
||||
<!-- to make our snapshot releases work with CI platforms -->
|
||||
<repository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<name>Sonatype Nexus Snapshots</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-nexus-releases</id>
|
||||
<name>Sonatype Nexus Releases</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/releases</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.graylog2</groupId>
|
||||
<artifactId>graylog2-server</artifactId>
|
||||
<version>${graylog.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Include source from test-jar to reuse test classes. -->
|
||||
<dependency>
|
||||
<groupId>org.graylog2</groupId>
|
||||
<artifactId>graylog2-server</artifactId>
|
||||
<version>${graylog.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource><directory>${web.build-dir}</directory></resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipAssembly>true</skipAssembly>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Graylog-Plugin-Properties-Path>${project.groupId}.${project.artifactId}</Graylog-Plugin-Properties-Path>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<configuration>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<configuration>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<mavenExecutorId>forked-path</mavenExecutorId>
|
||||
<tagNameFormat>@{project.version}</tagNameFormat>
|
||||
<preparationGoals>clean test</preparationGoals>
|
||||
<goals>package</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>jdeb</artifactId>
|
||||
<groupId>org.vafer</groupId>
|
||||
<version>1.4</version>
|
||||
<configuration>
|
||||
<deb>${project.build.directory}/${project.artifactId}-${project.version}.deb</deb>
|
||||
<dataSet>
|
||||
<data>
|
||||
<src>${project.build.directory}/${project.build.finalName}.jar</src>
|
||||
<type>file</type>
|
||||
<mapper>
|
||||
<type>perm</type>
|
||||
<prefix>${graylog.plugin-dir}</prefix>
|
||||
<filemode>644</filemode>
|
||||
<user>root</user>
|
||||
<group>root</group>
|
||||
</mapper>
|
||||
</data>
|
||||
</dataSet>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>rpm-maven-plugin</artifactId>
|
||||
<version>2.1.4</version>
|
||||
<configuration>
|
||||
<group>Application/Internet</group>
|
||||
<prefixes>
|
||||
<prefix>/usr</prefix>
|
||||
</prefixes>
|
||||
<defineStatements>
|
||||
<defineStatement>_unpackaged_files_terminate_build 0</defineStatement>
|
||||
<defineStatement>_binaries_in_noarch_packages_terminate_build 0</defineStatement>
|
||||
</defineStatements>
|
||||
<defaultFilemode>644</defaultFilemode>
|
||||
<defaultDirmode>755</defaultDirmode>
|
||||
<defaultUsername>root</defaultUsername>
|
||||
<defaultGroupname>root</defaultGroupname>
|
||||
<mappings>
|
||||
<mapping>
|
||||
<directory>${graylog.plugin-dir}</directory>
|
||||
<sources>
|
||||
<source>
|
||||
<location>${project.build.directory}/</location>
|
||||
<includes>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</includes>
|
||||
</source>
|
||||
</sources>
|
||||
</mapping>
|
||||
</mappings>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Package: [[name]]
|
||||
Version: [[version]]
|
||||
Architecture: all
|
||||
Maintainer: John Doe <you@example.org>
|
||||
Section: web
|
||||
Priority: optional
|
||||
Depends: graylog-server | graylog-radio
|
||||
Description: [[description]]
|
||||
Binary file not shown.
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
* as published by MongoDB, Inc.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* Server Side Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the Server Side Public License
|
||||
* along with this program. If not, see
|
||||
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
||||
*/
|
||||
package com.example.plugins.strlen;
|
||||
|
||||
import org.graylog.plugins.pipelineprocessor.EvaluationContext;
|
||||
import org.graylog.plugins.pipelineprocessor.ast.expressions.Expression;
|
||||
import org.graylog.plugins.pipelineprocessor.ast.functions.Function;
|
||||
import org.graylog.plugins.pipelineprocessor.ast.functions.FunctionArgs;
|
||||
import org.graylog.plugins.pipelineprocessor.ast.functions.FunctionDescriptor;
|
||||
import org.graylog.plugins.pipelineprocessor.ast.functions.ParameterDescriptor;
|
||||
|
||||
public class StringLengthFunction implements Function<Integer> {
|
||||
|
||||
public static final String NAME = "string_length";
|
||||
private static final String PARAM = "string";
|
||||
|
||||
private final ParameterDescriptor<String, String> valueParam = ParameterDescriptor
|
||||
.string(PARAM)
|
||||
.description("The string to calculate the length of. For example, passing 'foo' will return 3.")
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public Object preComputeConstantArgument(FunctionArgs functionArgs, String s, Expression expression) {
|
||||
return expression.evaluateUnsafe(EvaluationContext.emptyContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer evaluate(FunctionArgs functionArgs, EvaluationContext evaluationContext) {
|
||||
String target = valueParam.required(functionArgs, evaluationContext);
|
||||
|
||||
if (target == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return target.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunctionDescriptor<Integer> descriptor() {
|
||||
return FunctionDescriptor.<Integer>builder()
|
||||
.name(NAME)
|
||||
.description("Returns the length of a string")
|
||||
.params(valueParam)
|
||||
.returnType(Integer.class)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
* as published by MongoDB, Inc.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* Server Side Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the Server Side Public License
|
||||
* along with this program. If not, see
|
||||
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
||||
*/
|
||||
package com.example.plugins.strlen;
|
||||
|
||||
import org.graylog2.plugin.PluginMetaData;
|
||||
import org.graylog2.plugin.ServerStatus;
|
||||
import org.graylog2.plugin.Version;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class StringLengthFunctionMetaData implements PluginMetaData {
|
||||
private static final String PLUGIN_PROPERTIES = "com.example.plugins.graylog-plugin-function-strlen/graylog-plugin.properties";
|
||||
|
||||
@Override
|
||||
public String getUniqueId() {
|
||||
return "com.example.plugins.strlen.StringLengthFunctionPlugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "String length pipeline function";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "John Doe <you@example.org>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURL() {
|
||||
return URI.create("https://github.com/YourGitHubUsername/graylog-plugin-function-strlen");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return Version.fromPluginProperties(getClass(), PLUGIN_PROPERTIES, "version", Version.from(0, 0, 1, "unknown"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Pipeline function that returns the length of a string.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getRequiredVersion() {
|
||||
return Version.fromPluginProperties(getClass(), PLUGIN_PROPERTIES, "graylog.version", Version.from(2, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ServerStatus.Capability> getRequiredCapabilities() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
* as published by MongoDB, Inc.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* Server Side Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the Server Side Public License
|
||||
* along with this program. If not, see
|
||||
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
||||
*/
|
||||
package com.example.plugins.strlen;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.multibindings.MapBinder;
|
||||
import org.graylog.plugins.pipelineprocessor.ast.functions.Function;
|
||||
import org.graylog2.plugin.PluginConfigBean;
|
||||
import org.graylog2.plugin.PluginModule;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class StringLengthFunctionModule extends PluginModule {
|
||||
|
||||
@Override
|
||||
public Set<? extends PluginConfigBean> getConfigBeans() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
addMessageProcessorFunction(StringLengthFunction.NAME, StringLengthFunction.class);
|
||||
}
|
||||
|
||||
protected void addMessageProcessorFunction(String name, Class<? extends Function<?>> functionClass) {
|
||||
addMessageProcessorFunction(binder(), name, functionClass);
|
||||
}
|
||||
|
||||
public static MapBinder<String, Function<?>> processorFunctionBinder(Binder binder) {
|
||||
return MapBinder.newMapBinder(binder, TypeLiteral.get(String.class), new TypeLiteral<Function<?>>() {});
|
||||
}
|
||||
|
||||
public static void addMessageProcessorFunction(Binder binder, String name, Class<? extends Function<?>> functionClass) {
|
||||
processorFunctionBinder(binder).addBinding(name).to(functionClass);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
* as published by MongoDB, Inc.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* Server Side Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the Server Side Public License
|
||||
* along with this program. If not, see
|
||||
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
||||
*/
|
||||
package com.example.plugins.strlen;
|
||||
|
||||
import org.graylog2.plugin.Plugin;
|
||||
import org.graylog2.plugin.PluginMetaData;
|
||||
import org.graylog2.plugin.PluginModule;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class StringLengthFunctionPlugin implements Plugin {
|
||||
@Override
|
||||
public PluginMetaData metadata() {
|
||||
return new StringLengthFunctionMetaData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PluginModule> modules () {
|
||||
return Collections.<PluginModule>singletonList(new StringLengthFunctionModule());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
com.example.plugins.strlen.StringLengthFunctionPlugin
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# The plugin version
|
||||
version=${project.version}
|
||||
|
||||
# The required Graylog server version
|
||||
graylog.version=${graylog.version}
|
||||
|
||||
# When set to true (the default) the plugin gets a separate class loader
|
||||
# when loading the plugin. When set to false, the plugin shares a class loader
|
||||
# with other plugins that have isolated=false.
|
||||
#
|
||||
# Do not disable this unless this plugin depends on another plugin!
|
||||
isolated=true
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
* as published by MongoDB, Inc.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* Server Side Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the Server Side Public License
|
||||
* along with this program. If not, see
|
||||
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
||||
*/
|
||||
import 'webpack-entry';
|
||||
|
||||
import { PluginManifest, PluginStore } from 'graylog-web-plugin/plugin';
|
||||
|
||||
import packageJson from '../../package.json';
|
||||
|
||||
const manifest = new PluginManifest(packageJson, {
|
||||
/* This is the place where you define which entities you are providing to the web interface.
|
||||
Right now you can add routes and navigation elements to it.
|
||||
|
||||
Examples: */
|
||||
|
||||
// Adding a route to /sample, rendering YourReactComponent when called:
|
||||
|
||||
// routes: [
|
||||
// { path: '/sample', component: YourReactComponent, permissions: 'inputs:create' },
|
||||
// ],
|
||||
|
||||
// Adding an element to the top navigation pointing to /sample named "Sample":
|
||||
|
||||
// navigation: [
|
||||
// { path: '/sample', description: 'Sample' },
|
||||
// ]
|
||||
});
|
||||
|
||||
PluginStore.register(manifest);
|
||||
|
|
@ -0,0 +1 @@
|
|||
com.example.plugins.strlen.StringLengthFunctionPlugin
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# The plugin version
|
||||
version=1.0.0-SNAPSHOT
|
||||
|
||||
# The required Graylog server version
|
||||
graylog.version=5.1.5
|
||||
|
||||
# When set to true (the default) the plugin gets a separate class loader
|
||||
# when loading the plugin. When set to false, the plugin shares a class loader
|
||||
# with other plugins that have isolated=false.
|
||||
#
|
||||
# Do not disable this unless this plugin depends on another plugin!
|
||||
isolated=true
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<failsafe-summary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/failsafe-summary.xsd" result="254" timeout="false">
|
||||
<completed>0</completed>
|
||||
<errors>0</errors>
|
||||
<failures>0</failures>
|
||||
<skipped>0</skipped>
|
||||
<failureMessage xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
|
||||
</failsafe-summary>
|
||||
Binary file not shown.
|
|
@ -0,0 +1,5 @@
|
|||
#Generated by Apache Maven
|
||||
#Wed May 07 16:23:57 EDT 2025
|
||||
groupId=com.example.plugins
|
||||
artifactId=graylog-plugin-function-strlen
|
||||
version=1.0.0-SNAPSHOT
|
||||
Binary file not shown.
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
* as published by MongoDB, Inc.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* Server Side Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the Server Side Public License
|
||||
* along with this program. If not, see
|
||||
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
||||
*/
|
||||
const path = require('path');
|
||||
const { PluginWebpackConfig } = require('graylog-web-plugin');
|
||||
const { loadBuildConfig } = require('graylog-web-plugin');
|
||||
|
||||
// Remember to use the same name here and in `getUniqueId()` in the java MetaData class
|
||||
module.exports = new PluginWebpackConfig(__dirname, 'com.example.plugins.strlen.StringLengthFunctionPlugin', loadBuildConfig(path.resolve(__dirname, './build.config')), {
|
||||
// Here goes your additional webpack configuration.
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue