forked from grafana/agent-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request grafana#33 from grafana/deployment-label
Deployment label, Scrape Jobs for Meta Monitoring, Log Metrics
- Loading branch information
Showing
13 changed files
with
822 additions
and
17 deletions.
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
40 changes: 40 additions & 0 deletions
40
modules/kubernetes/logs/metrics/post-process-bytes-lines.river
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,40 @@ | ||
/* | ||
Module: pre-process-lines-bytes-metrics | ||
Description: Generates metrics for the number of lines and bytes in the log line before any processing is done | ||
*/ | ||
argument "forward_to" { | ||
// comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" | ||
optional = false | ||
} | ||
|
||
export "process" { | ||
value = loki.process.pre_process_lines_bytes_metrics | ||
} | ||
|
||
loki.process "pre_process_lines_bytes_metrics" { | ||
forward_to = argument.forward_to.value | ||
|
||
stage.metrics { | ||
metric.counter { | ||
name = "lines_total" | ||
description = "total number of log lines ingested, processed and forwarded for storage" | ||
prefix = "log_" | ||
match_all = true | ||
action = "inc" | ||
max_idle_duration = "24h" | ||
} | ||
} | ||
|
||
stage.metrics { | ||
metric.counter { | ||
name = "bytes_total" | ||
description = "total log bytes ingested, processed and forwarded for storage" | ||
prefix = "log_" | ||
match_all = true | ||
count_entry_bytes = true | ||
action = "add" | ||
max_idle_duration = "24h" | ||
} | ||
} | ||
|
||
} |
94 changes: 94 additions & 0 deletions
94
modules/kubernetes/logs/metrics/pre-process-bytes-lines.river
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,94 @@ | ||
/* | ||
Module: pre-process-lines-bytes-metrics | ||
Description: Generates metrics for the number of lines and bytes in the log line before any processing is done | ||
*/ | ||
argument "forward_to" { | ||
// comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" | ||
optional = false | ||
} | ||
|
||
argument "keep_labels" { | ||
optional = true | ||
// comment = "List of labels to keep before the log message is written to Loki" | ||
default = [ | ||
"app", | ||
"cluster", | ||
"component", | ||
"container", | ||
"deployment", | ||
"env", | ||
"filename", | ||
"instance", | ||
"job", | ||
"level", | ||
"log_type", | ||
"namespace", | ||
"region", | ||
"service", | ||
"squad", | ||
"team", | ||
] | ||
} | ||
|
||
argument "git_repo" { | ||
optional = true | ||
default = coalesce(env("GIT_REPO"), "https://github.com/grafana/agent-modules.git") | ||
} | ||
|
||
argument "git_rev" { | ||
optional = true | ||
default = coalesce(env("GIT_REV"), env("GIT_REVISION"), env("GIT_BRANCH"), "main") | ||
} | ||
|
||
argument "git_pull_freq" { | ||
// comment = "How often to pull the git repo, the default is 0s which means never pull" | ||
optional = true | ||
default = "0s" | ||
} | ||
|
||
export "process" { | ||
value = module.git.label_keep.exports.process | ||
} | ||
|
||
// drop any labels that are not in the keep_labels list | ||
// this is because the metrics generated below will keep the full set of labels currently attached to the log line | ||
// we want those to line up with what we're keeping | ||
module.git "label_keep" { | ||
repository = argument.git_repo.value | ||
revision = argument.git_rev.value | ||
pull_frequency = argument.git_pull_freq.value | ||
path = "modules/kubernetes/logs/labels/keep-labels.river" | ||
|
||
arguments { | ||
forward_to = [loki.process.pre_process_lines_bytes_metrics.receiver] | ||
keep_labels = argument.keep_labels.value | ||
} | ||
} | ||
|
||
loki.process "pre_process_lines_bytes_metrics" { | ||
forward_to = [] // does not forward anywhere, just generates metrics | ||
|
||
stage.metrics { | ||
metric.counter { | ||
name = "lines_pre_total" | ||
description = "total number of log lines ingested before processing" | ||
prefix = "log_" | ||
match_all = true | ||
action = "inc" | ||
max_idle_duration = "24h" | ||
} | ||
} | ||
|
||
stage.metrics { | ||
metric.counter { | ||
name = "bytes_pre_total" | ||
description = "total number of log bytes ingested before processing" | ||
prefix = "log_" | ||
match_all = true | ||
count_entry_bytes = true | ||
action = "add" | ||
max_idle_duration = "24h" | ||
} | ||
} | ||
|
||
} |
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
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
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
Oops, something went wrong.