Skip to content

Commit

Permalink
googlemanagedprometheusexporter: add config option for cumulative nor…
Browse files Browse the repository at this point in the history
…malization (#36357)

This change will allow the configurer to set whether cumulative
normalization should be set. The main benefit from this is so we can
send the first point immediately as we see them. This will allow our
serverless offering to unfork the exporter:

https://github.com/GoogleCloudPlatform/run-gmp-sidecar/tree/main/collector/exporter/googlemanagedprometheusexporter

Signed-off-by: Ridwan Sharif <ridwanmsharif@google.com>
  • Loading branch information
ridwanmsharif authored Nov 13, 2024
1 parent ed00c27 commit f2c9c3c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
27 changes: 27 additions & 0 deletions .chloggen/configure-cumulative-normalization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: googlemanagedprometheus

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add `CumulativeNormalization` config option to allow users to configure to specify whether to report normalized or un-normalized points. Defaults to normalized.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36357]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
6 changes: 6 additions & 0 deletions exporter/googlemanagedprometheusexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ type MetricConfig struct {
ClientConfig collector.ClientConfig `mapstructure:",squash"`
Config googlemanagedprometheus.Config `mapstructure:",squash"`
ResourceFilters []collector.ResourceFilter `mapstructure:"resource_filters"`
// CumulativeNormalization normalizes cumulative metrics without start times or with
// explicit reset points by subtracting subsequent points from the initial point.
// It is enabled by default. Since it caches starting points, it may result in
// increased memory usage.
CumulativeNormalization bool `mapstructure:"cumulative_normalization"`
}

func (c *GMPConfig) toCollectorConfig() collector.Config {
// start with whatever the default collector config is.
cfg := collector.DefaultConfig()
cfg.MetricConfig.Prefix = c.MetricConfig.Prefix
cfg.MetricConfig.CumulativeNormalization = c.MetricConfig.CumulativeNormalization
if c.MetricConfig.Prefix == "" {
cfg.MetricConfig.Prefix = "prometheus.googleapis.com"
}
Expand Down
1 change: 1 addition & 0 deletions exporter/googlemanagedprometheusexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func TestLoadConfig(t *testing.T) {
Regex: "host.id",
},
},
CumulativeNormalization: false,
},
},
QueueSettings: exporterhelper.QueueConfig{
Expand Down
3 changes: 2 additions & 1 deletion exporter/googlemanagedprometheusexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func createDefaultConfig() component.Config {
QueueSettings: exporterhelper.NewDefaultQueueConfig(),
GMPConfig: GMPConfig{
MetricConfig: MetricConfig{
Config: googlemanagedprometheus.DefaultConfig(),
Config: googlemanagedprometheus.DefaultConfig(),
CumulativeNormalization: true,
},
},
}
Expand Down
23 changes: 11 additions & 12 deletions exporter/googlemanagedprometheusexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,22 @@ exporters:
metric:
prefix: my-metric-domain.com
add_metric_suffixes: false
cumulative_normalization: false
extra_metrics_config:
enable_target_info: false
enable_scope_info: false
resource_filters:
- prefix: "cloud"
- prefix: "k8s"
- prefix: "faas"
- regex: "container.id"
- regex: "process.pid"
- regex: "host.name"
- regex: "host.id"

- prefix: "cloud"
- prefix: "k8s"
- prefix: "faas"
- regex: "container.id"
- regex: "process.pid"
- regex: "host.name"
- regex: "host.id"

service:
pipelines:
traces:
receivers: [nop]
processors: [nop]
exporters: [googlemanagedprometheus]

receivers: [nop]
processors: [nop]
exporters: [googlemanagedprometheus]

0 comments on commit f2c9c3c

Please sign in to comment.