Graylog Server

repository·master·Indexed 27 days ago

https://github.com/graylog2/graylog2-server

The core server for Graylog, including tools for developing web interface plugins, Opensearch configuration management, and protobuf specifications. It provides archetypes and helper modules like graylog-web-plugin for plugin development, as well as documentation for installing and configuring plugins such as the CEF message input and NetFlow collector.

Tokens
38.4K
Snippets
61
Records
315
Agent score
93%

What's inside graylog2-server

  1. NetFlow Plugin Capabilities and Compatibility

    master

    The NetFlow plugin is designed to receive data from Flow exporters and convert them into Graylog messages.

    Compatibility:

    • Required Graylog version: 2.3.0 and later.

    Supported Versions & Features:

    • NetFlow V9: Full support.
    • IPv6: Supports IPv6 addresses without conversion.
    • NetFlow V5: Handles all fields from the fixed V5 format.
    • Cisco ASA 5500: Supports events from Cisco ASA 5500, including firewall and routing events (Note: there may be significant duplication of typical syslog reporting in v9 reporting).
  2. Understand Opensearch configuration handling

    master

    Graylog manages Opensearch configuration using two distinct approaches to ensure the correct settings are applied to the runtime environment:

    1. Common Configuration: Files located in main/resources/opensearch/config/common are considered base configuration. These files are copied to the managed Opensearch process's read-write location during every process start. This action overrides any existing files from previous runs.
    2. Version-Specific Configuration: Files located in subdirectories named after the Opensearch SemVer (e.g., main/resources/opensearch/config/2.19.5) are copied specifically for that version.

    During startup, the system combines these two sources to prepare the runtime configuration.

  3. Handle date times in the Graylog Web Interface

    master

    Graylog follows specific standards for date time handling to ensure consistency between the backend and UI:

    Data Exchange and Storage

    • Backend Communication: All dates sent to or received from the backend must be in UTC and formatted according to ISO 8601 (e.g., 2010-07-30T16:03:25.000Z).
    • State Management: Use the ISO 8601 UTC format when storing date times in UI component states.

    UI Display

    • Timezones: Dates must always be displayed in the user's local timezone.
    • Display Components:
      • Use the Timestamp component for standard date/time display.
      • Use the RelativeTime component to display human-readable relative time (e.g., "2 minutes ago").
    • Hooks: Access timezone-aware functionality via the useUserDateTime hook.

    Transformations

    • Utility Usage: For all date time transformations, use the DateTime utils instead of using moment directly. This abstraction allows the project to swap underlying libraries without breaking your implementation.
  4. Develop the Graylog CEF message input plugin

    master

    To build the plugin from source, you need Maven 3 and Java 8 or higher.

    1. Clone the repository.
    2. Build the JAR file using mvn package.
    3. (Optional) Create DEB or RPM packages using mvn jdeb:jdeb and mvn rpm:rpm.
    4. Copy the generated JAR from the target directory to your Graylog plugin directory.
    5. Restart Graylog.
    mvn package
    # Optional: create packages
    mvn jdeb:jdeb
    mvn rpm:rpm
  5. Enable hot reloading for web interface development

    master

    To improve the development experience for the web interface portion of your plugin, you can use hot reloading by linking your plugin into the Graylog web interface directory. Follow these steps:

    1. Clone the Graylog server repository.
    2. Navigate to the graylog2-web-interface directory.
    3. Create a symbolic link from your plugin directory to the plugin/ directory.
    4. Install dependencies and start the development server.
    git clone https://github.com/Graylog2/graylog2-server.git
    cd graylog2-server/graylog2-web-interface
    ln -s $YOURPLUGIN plugin/
    npm install && npm start
  6. Access theme properties in components using GraylogThemeProvider

    master

    The Graylog Web Interface uses a GraylogThemeProvider (defined in src/theme/GraylogThemeProvider.jsx) to wrap the application. This provider makes the global theme object available to all components via the theme prop through styled-components.

    To use theme values (such as colors) in your styled components, destructure theme from the props function within a styled declaration.

    const StyledElement = styled.div(
      ({ theme }) => css`
        background-color: ${theme.colors.global.contentBackground};
      `,
    );
  7. Configure Maven Enforcer Rule for Graylog Plugins

    master

    Plugin builds inheriting from graylog-plugin-parent or graylog-plugin-web-parent now enforce the requireUpperBoundDeps rule. This rule fails the build if a transitive dependency resolves to a version lower than what another dependency in the plugin requires.

    To resolve build failures:

    1. Update the outdated dependency to the required version.
    2. Or, add a <dependencyManagement> entry for the flagged artifact using the highest required version indicated in the error message.
    3. If you cannot align dependencies, you can override the enforce-versions execution of the maven-enforcer-plugin in your own POM.
  8. Follow Graylog form layout rules

    master

    When building forms in Graylog, adhere to the following layout principles to ensure usability and speed:

    • Single Column Layout: Forms must always be laid out in a single column. Multi-column layouts are discouraged as they increase completion time and cause users to skip fields.
    • Two-Column Exception: You may use two columns in a single row only when fields are semantically a single unit (e.g., first / last name, key / value, or start / end date). In these cases, both fields in the pair must be of equal width.
    • Grouping: Use section labels and dividers to group related fields. Limit forms to a maximum of 3 to 4 groups per form or step.
    • Field Ordering: Within a group, place required fields before optional fields.
    • Advanced Options: Hide fields that most users will not need behind a collapsible section labeled "Advanced options" to prevent form clutter.
  9. Run the frontend documentation and component gallery locally

    master

    While the online documentation is available at https://graylog2.github.io/frontend-documentation/, you can run a local version to contribute or view different branches:

    1. Navigate to the docs directory: cd docs
    2. Install dependencies: yarn install
    3. Start the documentation server: yarn run docs:server
    4. Access the documentation at http://localhost:6060.
    cd docs
    yarn install
    yarn run docs:server
  10. Configure plugin properties during project generation

    master

    When running the archetype:generate command, you will be prompted to define several properties. Key properties include:

    • groupId: The Maven group ID for your plugin (e.g., org.graylog.plugins).
    • artifactId: The unique identifier for your plugin project (e.g., graylog-plugin-twitter).
    • package: The Java package name where your code will reside (e.g., org.graylog.plugins.twitter).
    • pluginClassName: The name of the main class that implements the Graylog plugin interface (e.g., Twitter).