-
Notifications
You must be signed in to change notification settings - Fork 504
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
Add deriving metrics from logs use case to Data Prepper #6248
Merged
Merged
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
39d2161
Add use case to Data Prepper
vagimeli 06fb2a3
Add content
vagimeli a0fe1f0
Copy edits
vagimeli a5bcd1b
Merge branch 'main' into metrics-logs
vagimeli a47d898
Merge branch 'main' into metrics-logs
vagimeli 217cee3
Merge branch 'main' into metrics-logs
vagimeli 803b748
Merge branch 'main' into metrics-logs
vagimeli 364619c
Update metrics-logs.md
vagimeli 6ecd3db
Merge branch 'main' into metrics-logs
vagimeli e60fdb9
Merge branch 'main' into metrics-logs
vagimeli 223b20c
Merge branch 'main' into metrics-logs
vagimeli a6b0a6a
Merge branch 'main' into metrics-logs
vagimeli 39a2c4a
Update _data-prepper/common-use-cases/metrics-logs.md
vagimeli 111b669
Update _data-prepper/common-use-cases/metrics-logs.md
vagimeli 889cada
Merge branch 'main' into metrics-logs
vagimeli 8c54196
Update _data-prepper/common-use-cases/metrics-logs.md
vagimeli e453c50
Update _data-prepper/common-use-cases/metrics-logs.md
vagimeli d38691d
Update _data-prepper/common-use-cases/metrics-logs.md
vagimeli c02adb0
Update _data-prepper/common-use-cases/metrics-logs.md
vagimeli 44500d8
Merge branch 'main' into metrics-logs
vagimeli c761ef5
Merge branch 'main' into metrics-logs
vagimeli db890e3
Merge branch 'main' into metrics-logs
vagimeli 4b0d81b
Merge branch 'main' into metrics-logs
vagimeli 3afc5da
Update metrics-logs.md
vagimeli 9cb87a5
Merge branch 'main' into metrics-logs
vagimeli 540b97c
Update metrics-logs.md
vagimeli 871bf11
Update _data-prepper/common-use-cases/metrics-logs.md
vagimeli 9b0b40a
Merge branch 'main' into metrics-logs
vagimeli 20a6d8f
Merge branch 'main' into metrics-logs
vagimeli 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 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,70 @@ | ||
--- | ||
layout: default | ||
title: Deriving metrics from logs | ||
parent: Common use cases | ||
nav_order: 15 | ||
--- | ||
|
||
# Deriving metrics from logs | ||
|
||
You can use Data Prepper to derive metrics from logs. | ||
|
||
The following example pipeline receives incoming logs using the [`http` source plugin]({{site.url}}{{site.baseurl}}/data-prepper/pipelines/configuration/sources/http-source) and the [`grok` processor]({{site.url}}{{site.baseurl}}/data-prepper/pipelines/configuration/processors/grok/). It then uses the [`aggregate` processor]({{site.url}}{{site.baseurl}}/data-prepper/pipelines/configuration/processors/aggregate/) to extract the metric bytes aggregated during a 30-second window and derives histograms from the results. | ||
|
||
This pipeline writes data to two different OpenSearch indexes: | ||
|
||
- `logs`: This index stores the original, un-aggregated log events after being processed by the `grok` processor. | ||
- `histogram_metrics`: This index stores the derived histogram metrics extracted from the log events using the `aggregate` processor. | ||
|
||
The pipeline contains two sub-pipelines: | ||
|
||
- `apache-log-pipeline-with-metrics`: Receives logs through an HTTP client like FluentBit, uses `grok` to extract important values from the logs by matching the value in the log key against the [Apache Common Log Format](https://httpd.apache.org/docs/2.4/logs.html#accesslog). It then forwards the grokked logs to two destinations: | ||
vagimeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- An OpenSearch index named `logs` to store the original log events. | ||
- The `log-to-metrics-pipeline` for further aggregation and metric derivation. | ||
|
||
- `log-to-metrics-pipeline`: Receives the grokked logs from the `apache-log-pipeline-with-metrics` pipeline, aggregates the logs, and derives histogram metrics of bytes based on the values in the `clientip` and `request` keys. Finally, it sends the derived histogram metrics to an OpenSearch index named `histogram_metrics`. | ||
|
||
#### Example pipeline | ||
|
||
```json | ||
apache-log-pipeline-with-metrics: | ||
source: | ||
http: | ||
# Provide the path for ingestion. ${pipelineName} will be replaced with pipeline name configured for this pipeline. | ||
# In this case it would be "/apache-log-pipeline-with-metrics/logs". This will be the FluentBit output URI value. | ||
path: "/${pipelineName}/logs" | ||
processor: | ||
- grok: | ||
match: | ||
log: [ "%{COMMONAPACHELOG_DATATYPED}" ] | ||
sink: | ||
- opensearch: | ||
... | ||
index: "logs" | ||
- pipeline: | ||
name: "log-to-metrics-pipeline" | ||
|
||
log-to-metrics-pipeline: | ||
source: | ||
pipeline: | ||
name: "apache-log-pipeline-with-metrics" | ||
processor: | ||
- aggregate: | ||
# Specify the required identification keys | ||
identification_keys: ["clientip", "request"] | ||
action: | ||
histogram: | ||
# Specify the appropriate values for each of the following fields | ||
key: "bytes" | ||
record_minmax: true | ||
units: "bytes" | ||
buckets: [0, 25000000, 50000000, 75000000, 100000000] | ||
# Pick the required aggregation period | ||
group_duration: "30s" | ||
sink: | ||
- opensearch: | ||
... | ||
index: "histogram_metrics" | ||
``` | ||
{% include copy-curl.html %} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dlvenable Please review the text added at lines 14--27 and let me know if these additions address your feedback and are accurate. Thank you.