Skip to content

[Prometheus Receiver] Add in setting to enable server for Prometheus UI #29622

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ If you are looking for developer-facing changes, check out [CHANGELOG-API.md](./
See also `MemAvailable` in [/proc/meminfo](https://man7.org/linux/man-pages/man5/proc.5.html).

- `azuremonitorexporter`: Updated Azure Monitor Exporter service version from v2.0 to v2.1. (#29234)
- `prometheusreceiver`: Add optional config to enable the server for the Prometheus UI.

### 🧰 Bug fixes 🧰

Expand Down
4 changes: 4 additions & 0 deletions receiver/prometheusreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ The prometheus receiver also supports additional top-level options:
- **trim_metric_suffixes**: [**Experimental**] When set to true, this enables trimming unit and some counter type suffixes from metric names. For example, it would cause `singing_duration_seconds_total` to be trimmed to `singing_duration`. This can be useful when trying to restore the original metric names used in OpenTelemetry instrumentation. Defaults to false.
- **use_start_time_metric**: When set to true, this enables retrieving the start time of all counter metrics from the process_start_time_seconds metric. This is only correct if all counters on that endpoint started after the process start time, and the process is the only actor exporting the metric after the process started. It should not be used in "exporters" which export counters that may have started before the process itself. Use only if you know what you are doing, as this may result in incorrect rate calculations. Defaults to false.
- **start_time_metric_regex**: The regular expression for the start time metric, and is only applied when use_start_time_metric is enabled. Defaults to process_start_time_seconds.
- **enable_prometheus_ui_server**: [**Experimental**] When set to true, this enables the Prometheus UI server through the [Prometheus web handler](https://github.com/prometheus/prometheus/blob/main/web/web.go). The React app files will need to be accessible from the same directory location that the OpenTelemetry Collector is run from. See the [Prometheus UI README](https://github.com/prometheus/prometheus/blob/main/web/ui/README.md) for how to get a build of the app by running `npm run build`. This UI can be accessed through http://localhost:9090 while the OpenTelemetry Collector with the Prometheus Receiver is running.
- **prometheus_ui_server_port**: [**Experimental**] When ``enable_prometheus_ui_server`` is set to true, this setting overrides the default port of the server from `9090` to the `uint16` value specified.

For example,

Expand All @@ -120,6 +122,8 @@ receivers:
trim_metric_suffixes: true
use_start_time_metric: true
start_time_metric_regex: foo_bar_.*
enable_prometheus_ui_sever: true
prometheus_ui_server_port: 9091
config:
scrape_configs:
- job_name: 'otel-collector'
Expand Down
9 changes: 9 additions & 0 deletions receiver/prometheusreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ type Config struct {
// EnableProtobufNegotiation allows the collector to set the scraper option for
// protobuf negotiation when conferring with a prometheus client.
EnableProtobufNegotiation bool `mapstructure:"enable_protobuf_negotiation"`

// EnablePrometheusUIServer enables the receiver to host the Prometheus UI
// server in agent mode. This allows the user to view the config, service discovery,
// and targets for debugging purposes.
EnablePrometheusUIServer bool `mapstructure:"enable_prometheus_ui_server"`

// PrometheusUIServerPort overwrites the default port of 9090 for hosting
// the Prometheus UI server.
PrometheusUIServerPort uint16 `mapstructure:"prometheus_ui_server_port"`
}

type targetAllocator struct {
Expand Down
1 change: 1 addition & 0 deletions receiver/prometheusreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func TestLoadConfig(t *testing.T) {
assert.Equal(t, r1.EnableProtobufNegotiation, true)
assert.Equal(t, r1.StartTimeMetricRegex, "^(.+_)*process_start_time_seconds$")
assert.True(t, r1.ReportExtraScrapeMetrics)
assert.True(t, r1.EnablePrometheusUIServer)

assert.Equal(t, "http://my-targetallocator-service", r1.TargetAllocator.Endpoint)
assert.Equal(t, 30*time.Second, r1.TargetAllocator.Interval)
Expand Down
1 change: 1 addition & 0 deletions receiver/prometheusreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestCreateReceiver(t *testing.T) {
mReceiver, _ := createMetricsReceiver(context.Background(), creationSet, cfg, nil)
assert.NotNil(t, mReceiver)
assert.NotNil(t, mReceiver.(*pReceiver).cfg.PrometheusConfig.GlobalConfig)
require.NoError(t, mReceiver.Shutdown(context.Background()))
}

func TestFactoryCanParseServiceDiscoveryConfigs(t *testing.T) {
Expand Down
22 changes: 20 additions & 2 deletions receiver/prometheusreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.90.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.90.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.90.0
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/common v0.45.0
github.com/prometheus/prometheus v0.48.0
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -38,23 +39,25 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4 v4.2.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 v2.2.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go v1.47.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/digitalocean/godo v1.104.1 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v24.0.7+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/envoyproxy/go-control-plane v0.11.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
Expand All @@ -65,9 +68,15 @@ require (
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-zookeeper/zk v1.0.3 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
Expand Down Expand Up @@ -106,6 +115,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/klauspost/compress v1.17.3 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
Expand All @@ -123,10 +133,12 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.90.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.90.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
Expand All @@ -136,15 +148,18 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/alertmanager v0.26.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common/assets v0.2.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/exporter-toolkit v0.10.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/statsd_exporter v0.22.7 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21 // indirect
github.com/shirou/gopsutil/v3 v3.23.10 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tidwall/gjson v1.10.2 // indirect
Expand All @@ -156,6 +171,7 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/vultr/govultr/v2 v2.17.2 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.mongodb.org/mongo-driver v1.12.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.90.0 // indirect
go.opentelemetry.io/collector/config/configauth v0.90.0 // indirect
Expand Down Expand Up @@ -188,12 +204,14 @@ require (
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/goleak v1.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
Loading