GoogleCloudPlatform / run-gmp-sidecar

Apache License 2.0
6 stars 7 forks source link

Feature request: specify the metrics port for default config #5

Open tcnghia opened 5 months ago

tcnghia commented 5 months ago

Our container serves metrics at either port 9090 or 2112. I see that the default configuration expect the port to be 8080.

Currently I don't see an option to customize the metrics port. There is another option of specifying a whole collector config, but then I lose all the nicety of the default config.

Can we please allow specifying the metrics port through an env var like METRICS_PORT? If this approach sounds good, I would be happy to help add it.

ridwanmsharif commented 3 months ago

In order to configure the sidecar to scrape another port or path, you need to add a config that will look like:

apiVersion: monitoring.googleapis.com/v1beta
kind: RunMonitoring
metadata:
  name: <NAME>
spec:
  endpoints:
  - port: <PORT>
    path: /metrics
    interval: 30s

And use secret manager to store this custom configuration and have the sidecar use it (mounting the secret as a volume), docs here: https://cloud.google.com/stackdriver/docs/managed-prometheus/cloudrun-sidecar#sidecar-intro

We're evaluating whether its reasonable to have the config )like above) be stored as an env variable instead, in something like RUN_GMP_CONFIG, to avoid using secret manager. Would that help this use case as well?

costinm commented 3 months ago

https://github.com/GoogleCloudPlatform/run-gmp-sidecar/pull/23 should solve this as well - list of ports.

tcnghia commented 3 months ago

Thanks all. Both of these options are very helpful!

gitperr commented 1 month ago

It would be very useful to be able to toggle port setting to scrape via terraform, as well.