Skip to content

Commit

Permalink
Get Prometheus Metrics When Label Matcher Is Not Given (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethAmazon committed Jan 12, 2023
1 parent 0ded55f commit ffbf6d1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
10 changes: 10 additions & 0 deletions translator/tocwconfig/sampleConfig/prometheus_config_linux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@
label_matcher = "default"
metric_selectors = [".*"]
source_labels = ["Namespace"]

[[processors.emfProcessor.metric_declaration]]
dimensions = [["name"]]
metric_selectors = ["^.*$"]
source_labels = ["name"]

[[processors.emfProcessor.metric_declaration]]
dimensions = [["name"]]
metric_selectors = ["^node_cpu_guest_seconds_total$"]
source_labels = ["name"]
[processors.emfProcessor.metric_unit]
jvm_memory_bytes_used = "Bytes"
nginx_request_count = "Count"
14 changes: 14 additions & 0 deletions translator/tocwconfig/sampleConfig/prometheus_config_linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
"label_matcher": "default",
"metric_selectors": [".*"],
"source_labels": ["Namespace"]
},
{
"source_labels":["name"],
"dimensions":[
["name"]
],
"metric_selectors": ["^.*$"]
},
{
"source_labels":["name"],
"dimensions":[
["name"]
],
"metric_selectors": ["^node_cpu_guest_seconds_total$"]
}
]
}
Expand Down
16 changes: 16 additions & 0 deletions translator/tocwconfig/sampleConfig/prometheus_config_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ exporters:
separator: ;
metric_name_selectors:
- .*
- dimensions: [ ["name"] ]
label_matchers:
- label_names:
- name
regex: .*
separator: ;
metric_name_selectors:
- ^.*$
- dimensions: [ ["name"] ]
label_matchers:
- label_names:
- name
regex: .*
separator: ;
metric_name_selectors:
- ^node_cpu_guest_seconds_total$
namespace: CustomizedNamespace
no_verify_ssl: false
num_workers: 8
Expand Down
9 changes: 6 additions & 3 deletions translator/translate/otel/exporter/awsemf/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ func setPrometheusMetricDeclarations(conf map[string]interface{}, cfg *awsemfexp
// If no metric selectors are provided, that particular metric declaration is invalid
continue
}
sourceLabels, ok1 := metricDeclaration["source_labels"]
labelMatcher, ok2 := metricDeclaration["label_matcher"]
if ok1 && ok2 {
labelMatcher, ok := metricDeclaration["label_matcher"]
if !ok {
labelMatcher = ".*"
}
sourceLabels, ok := metricDeclaration["source_labels"]
if ok {
// OTel awsemfexporter allows specifying multiple label_matchers but CWA only allows specifying one
declaration["label_matchers"] = [...]map[string]interface{}{
{
Expand Down

0 comments on commit ffbf6d1

Please sign in to comment.