-
Notifications
You must be signed in to change notification settings - Fork 599
add unix input custom integration #18944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
leehinman
wants to merge
12
commits into
elastic:main
Choose a base branch
from
leehinman:16945_unix_custom
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
60364b0
add unix input custom integration
leehinman d434559
add CODEOWNERS
leehinman ec5f873
Fix PR in changelog
leehinman 83f91dd
fix owner in manifest
leehinman 3624ce8
trap the SIGHUP
leehinman 04f6cb1
switch to stream for testing
leehinman 6bb96b4
Add change to set permissions for socket dir
leehinman 1b3da99
respond to feedback
leehinman ee70194
update readme
leehinman e539c9b
Merge branch 'main' into 16945_unix_custom
leehinman 7d556c2
Merge branch 'main' into 16945_unix_custom
leehinman 43705dd
Merge branch 'main' into 16945_unix_custom
leehinman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| dependencies: | ||
| ecs: | ||
| reference: "git@v8.17.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # Custom Unix Logs Integration for Elastic | ||
|
|
||
| > **Note**: This AI-assisted guide was validated by our engineers. You may need to adjust the steps to match your environment. | ||
|
|
||
| ## Overview | ||
|
|
||
| The Custom Unix Logs integration for Elastic enables you to collect data through a stream-oriented Unix domain socket. It's a flexible solution for ingesting logs from local processes and applications into the Elastic Stack. By using this integration, you can centralize your log data, making it easier to monitor, search, and analyze your environment's activity. | ||
|
|
||
| ### Compatibility | ||
|
|
||
| The Custom Unix Logs integration is compatible with any process or application capable of writing to a Unix domain socket on the same host as the Elastic Agent. | ||
|
|
||
| This integration supports the following standards: | ||
| - Syslog standards: Supports devices compliant with `RFC 3164` (BSD syslog) and `RFC 5424` (The Syslog Protocol). | ||
| - Framing standards: Supports `RFC 6587` for octet-counted framing, which is commonly used in high-reliability log transmission. | ||
|
|
||
| ### How it works | ||
|
|
||
| This integration collects data by having an Elastic Agent listen on a Unix domain socket at a specified path. The agent creates the socket file and waits for local processes to connect and send data. When a process writes data to the socket, the Elastic Agent receives and processes it. | ||
|
|
||
| Once received, the data is processed according to your configuration—whether it's raw text, syslog formatted, or uses specific framing. The Elastic Agent then forwards the logs to your Elastic deployment, where you can analyze them using Kibana. | ||
|
|
||
| ## What data does this integration collect? | ||
|
|
||
| The Custom Unix Logs integration collects log messages of the following types: | ||
| - Raw streams: Any text-based data sent over the Unix domain socket, typically separated by newline characters or other delimiters. | ||
| - Syslog messages: Structured messages following RFC 3164 or RFC 5424, which include metadata such as facility, severity, and timestamps. | ||
|
|
||
| This integration includes the following data stream: | ||
| - `unix.generic`: This is the default data stream. It captures the raw message payload in the `message` field. If you enable Syslog parsing, additional ECS fields are populated from the syslog header. | ||
|
|
||
| ### Supported use cases | ||
|
|
||
| - Local application logging: Applications on the same host can write log events directly to the Unix socket, eliminating the need for network connectivity. | ||
| - System daemon log collection: Collect logs from system daemons that support Unix socket output. | ||
| - Syslog ingestion: Collect syslog-formatted messages from local processes using `logger` or other syslog-compatible tools. | ||
| - Secure local log aggregation: Since Unix domain sockets are filesystem objects, standard Unix file permissions (`group`, `mode`) can be used to control which processes can send data. | ||
|
|
||
| ## What do I need to use this integration? | ||
|
|
||
| ### Elastic prerequisites | ||
|
|
||
| - Elastic Agent: A running Elastic Agent managed by a Fleet policy or configured in standalone mode. | ||
| - The Elastic Agent must have write permission to the directory where the socket will be created. | ||
|
|
||
| ### Source prerequisites | ||
|
|
||
| - The sending process must run on the same host as the Elastic Agent. | ||
| - The sending process must have permission to write to the Unix socket (controlled via the `group` and `mode` options). | ||
|
|
||
| ## How do I deploy this integration? | ||
|
|
||
| ### Agent-based deployment | ||
|
|
||
| Elastic Agent must be installed. For more details, check the Elastic Agent [installation instructions](https://www.elastic.co/guide/en/fleet/current/elastic-agent-installation.html). You can install only one Elastic Agent per host. | ||
|
|
||
| ### Set up steps in Kibana | ||
|
|
||
| You'll follow these steps to add and configure the integration in Kibana: | ||
|
|
||
| 1. Navigate to **Management > Integrations** in Kibana. | ||
| 2. Search for **Custom Unix Logs** and select it. | ||
| 3. Click **Add Custom Unix Logs**. | ||
| 4. Configure the integration settings: | ||
| - **Socket Path**: The filesystem path where the Unix domain socket will be created (e.g. `/tmp/example.sock`). | ||
| - **Socket Type**: The socket variety: `stream` or `datagram`. The default is `stream`. | ||
| - **Dataset Name**: The name of the dataset where logs will be written. The default is `unix.generic`. | ||
| - **Framing**: Specify how the Agent identifies the end of a log message. Options include `delimiter` (default) or `rfc6587`. | ||
| - **Line Delimiter**: The character used to split incoming data into separate log events. The default is `\n`. | ||
| - **Max Message Size**: The maximum allowed size for a single log message. The default is `20MiB`. | ||
| - **Syslog Parsing**: Enable this boolean if the incoming data is in standard Syslog format (RFC3164/5424). | ||
| 5. Optionally configure advanced options: | ||
| - **Socket Group**: The group ownership for the created Unix socket. | ||
| - **Socket Mode**: File permissions for the socket as an octal string (e.g. `0660`). | ||
| - **Max Connections**: Maximum number of simultaneous connections. | ||
| - **Timeout**: Duration of inactivity before a connection is closed. | ||
| 6. (Optional) Provide a **Custom Ingest Pipeline** name if you've already defined processing logic in Elasticsearch. | ||
| 7. Click **Save and Continue** to deploy the configuration to your Agents. | ||
|
|
||
| ### Configure the sending application | ||
|
|
||
| Once the Elastic Agent is running with this integration, configure your application to send data to the socket path you configured: | ||
|
|
||
| For rsyslog: | ||
| ``` | ||
| *.* unix-stream:/tmp/elastic-agent.sock | ||
| ``` | ||
|
|
||
| Using the `logger` command: | ||
| ```bash | ||
| logger -u /tmp/elastic-agent.sock "This is a test message" | ||
| ``` | ||
|
|
||
| Using `socat`: | ||
| ```bash | ||
| echo "Test log message" | socat - UNIX-CONNECT:/tmp/elastic-agent.sock | ||
| ``` | ||
|
|
||
| Using `nc` (if it supports Unix sockets): | ||
| ```bash | ||
| echo "Test log message" | nc -U /tmp/elastic-agent.sock | ||
| ``` | ||
|
|
||
| ### Validation | ||
|
|
||
| After configuration, verify that data is flowing correctly: | ||
|
|
||
| 1. Send a test message to the socket: | ||
| ```bash | ||
| echo "Integration Validation Test Message $(date)" | socat - UNIX-CONNECT:/tmp/elastic-agent.sock | ||
| ``` | ||
|
|
||
| 2. Check for the data in Kibana: | ||
| 1. Navigate to **Analytics > Discover**. | ||
|
Check warning on line 114 in packages/unix/_dev/build/docs/README.md
|
||
| 2. Select the `logs-*` data view. | ||
| 3. Enter this KQL filter: `data_stream.dataset : "unix.generic"` | ||
| 4. Verify that logs appear in the results and confirm these fields are populated: | ||
| - `event.dataset` (should be `unix.generic`) | ||
| - `message` (containing the test message) | ||
| - `input.type` (should indicate `unix`) | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| For help with Elastic ingest tools, check [Common problems](https://www.elastic.co/docs/troubleshoot/ingest/fleet/common-problems). | ||
|
|
||
| ### Common configuration issues | ||
|
|
||
| - Socket creation failure: | ||
| - Verify that the Elastic Agent has write permission to the directory containing the socket path. | ||
| - Ensure no file already exists at the configured socket path. | ||
| - Permission denied when connecting: | ||
| - If client processes cannot connect to the socket, adjust the `group` and `mode` options to allow the appropriate users or groups access. | ||
| - Dataset naming restriction: | ||
| - If data isn't appearing, check your integration configuration for hyphens in the `Dataset Name`. Hyphens aren't supported in this field and will cause ingestion issues. | ||
| - Parsing failures: | ||
| - If data appears in Kibana but doesn't parse correctly, check the `error.message` field. This often happens if you've enabled `Syslog Parsing` but the incoming logs don't strictly adhere to RFC 3164 or RFC 5424. | ||
|
|
||
| ## Performance and scaling | ||
|
|
||
| For more information on architectures that can be used for scaling this integration, check the [Ingest Architectures](https://www.elastic.co/docs/manage-data/ingest/ingest-reference- | ||
| architectures) documentation. | ||
|
|
||
| ## Reference | ||
|
|
||
| ### Vendor documentation links | ||
|
|
||
| - [Filebeat Unix Input](https://www.elastic.co/docs/reference/beats/filebeat/filebeat-input-unix) | ||
| - [RFC 3164: The BSD Syslog Protocol](https://datatracker.ietf.org/doc/html/rfc3164) | ||
| - [RFC 5424: The Syslog Protocol](https://datatracker.ietf.org/doc/html/rfc5424) | ||
| - [RFC 6587: Transmission of Syslog Messages over TCP](https://datatracker.ietf.org/doc/html/rfc6587) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| version: '2.3' | ||
| services: | ||
| setup-permissions: | ||
| image: busybox | ||
| command: chmod 1777 /tmp | ||
| volumes: | ||
| - ${SERVICE_LOGS_DIR}:/tmp | ||
| test-unix: | ||
| image: docker.elastic.co/observability/stream:v0.21.0 | ||
| depends_on: | ||
| setup-permissions: | ||
| condition: service_completed_successfully | ||
| volumes: | ||
| - ./sample_logs:/sample_logs:ro | ||
| - ${SERVICE_LOGS_DIR}:/tmp | ||
| command: log --start-signal=SIGHUP --delay=5s --addr /tmp/test.sock -p=unix /sample_logs/test-unix.log | ||
| test-syslog: | ||
| image: docker.elastic.co/observability/stream:v0.21.0 | ||
| depends_on: | ||
| setup-permissions: | ||
| condition: service_completed_successfully | ||
| volumes: | ||
| - ./sample_logs:/sample_logs:ro | ||
| - ${SERVICE_LOGS_DIR}:/tmp | ||
| command: log --start-signal=SIGHUP --delay=5s --addr /tmp/test-syslog.sock -p=unix /sample_logs/test-unix.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <134>1 2020-03-29T13:19:20Z testhostname testproductname 1930 - - some longer testmessage. - a {2:2}. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| service: test-syslog | ||
| service_notify_signal: SIGHUP | ||
| input: unix | ||
| vars: | ||
| data_stream.dataset: unix.generic | ||
| path: "{{{SERVICE_LOGS_DIR}}}/test-syslog.sock" | ||
| syslog: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| service: test-unix | ||
| service_notify_signal: SIGHUP | ||
| input: unix | ||
| vars: | ||
| data_stream.dataset: unix.generic | ||
| path: "{{{SERVICE_LOGS_DIR}}}/test.sock" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| {{#if use_logs_stream}} | ||
| index: logs.ecs | ||
| {{else}} | ||
| data_stream: | ||
| dataset: {{data_stream.dataset}} | ||
| {{/if}} | ||
| path: {{path}} | ||
| {{#if socket_type}} | ||
| socket_type: {{socket_type}} | ||
| {{/if}} | ||
| {{#if pipeline}} | ||
| pipeline: {{pipeline}} | ||
| {{/if}} | ||
| {{#if max_message_size}} | ||
| max_message_size: {{max_message_size}} | ||
| {{/if}} | ||
| {{#if framing}} | ||
| framing: {{framing}} | ||
| {{/if}} | ||
| {{#if line_delimiter}} | ||
| line_delimiter: {{line_delimiter}} | ||
| {{/if}} | ||
| {{#if max_connections}} | ||
| max_connections: {{max_connections}} | ||
| {{/if}} | ||
| {{#if timeout}} | ||
| timeout: {{timeout}} | ||
| {{/if}} | ||
| {{#if group}} | ||
| group: {{group}} | ||
| {{/if}} | ||
| {{#if mode}} | ||
| mode: {{mode}} | ||
| {{/if}} | ||
| {{#if keep_null}} | ||
| keep_null: {{keep_null}} | ||
| {{/if}} | ||
| {{#if tags}} | ||
| tags: | ||
| {{#if preserve_original_event}} | ||
| - preserve_original_event | ||
| {{/if}} | ||
| {{#each tags as |tag i|}} | ||
| - {{tag}} | ||
| {{/each}} | ||
| {{else if preserve_original_event}} | ||
| tags: | ||
| - preserve_original_event | ||
| {{/if}} | ||
| {{#contains "forwarded" tags}} | ||
| publisher_pipeline.disable_host: true | ||
| {{/contains}} | ||
| {{#if processors}} | ||
| processors: | ||
| {{#if preserve_original_event}} | ||
| - copy_fields: | ||
| fields: | ||
| - from: message | ||
| to: event.original | ||
| {{/if}} | ||
| {{#if syslog}} | ||
| - syslog: | ||
| {{syslog_options}} | ||
| {{/if}} | ||
| {{processors}} | ||
| {{else if syslog}} | ||
| processors: | ||
| {{#if preserve_original_event}} | ||
| - copy_fields: | ||
| fields: | ||
| - from: message | ||
| to: event.original | ||
| {{/if}} | ||
| - syslog: | ||
| {{syslog_options}} | ||
| {{else if preserve_original_event}} | ||
| processors: | ||
| - copy_fields: | ||
| fields: | ||
| - from: message | ||
| to: event.original | ||
| {{/if}} | ||
|
AndersonQ marked this conversation as resolved.
|
||
|
|
||
| {{custom}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| - version: "1.0.0" | ||
|
AndersonQ marked this conversation as resolved.
|
||
| changes: | ||
| - description: Initial Release | ||
| type: enhancement | ||
| link: https://github.com/elastic/integrations/pull/18944 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.