keda icon indicating copy to clipboard operation
keda copied to clipboard

Provide operational metrics in OpenTelemetry Collector

Open tomkerkhove opened this issue 2 years ago • 11 comments

Proposal

Provide operational metrics, that we have for Prometheus today, but push them to an OpenTelemetry Collector through OTEL.

Use-Case

Allow end-users to choose which metrics platform to use, instead of only supporting Prometheus.

Status

  • [x] Feature implementation
  • [x] Provide docs
  • [ ] Integrate in Helm chart

Anything else?

A proposal is open on https://github.com/kedacore/keda/issues/1281 to bring scaler metrics to OpenTelemetry Collector as well.

tomkerkhove avatar May 30 '22 05:05 tomkerkhove

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 29 '22 06:07 stale[bot]

This issue has been automatically closed due to inactivity.

stale[bot] avatar Aug 08 '22 07:08 stale[bot]

@ilyalexin this is the issue that we discussed as a good starting point for OTEL Collector integration.

This should be supported in both Operator & Metric Server and have parity with https://keda.sh/docs/2.9/operate/prometheus/.

tomkerkhove avatar Sep 27 '22 15:09 tomkerkhove

Related: https://github.com/kedacore/keda/pull/3695

tomkerkhove avatar Sep 27 '22 15:09 tomkerkhove

In order to resolve implement this feature one need to import opentelemetry sdk At this moment keda has indirect dependency to opentelemetry v0.20.0 through k8s/api-server v0.25.4

In order to use opentelemtry v1.0+ we need to update api-server to v0.26.0

This work is already in progress under https://github.com/kedacore/keda/pull/4107

ilaleksin avatar Jan 17 '23 13:01 ilaleksin

@kedacore/keda-maintainers Do we have an agreement that this is a nice addition?

tomkerkhove avatar Jul 06 '23 07:07 tomkerkhove

yeah, I think that generating OpenTelemetry data is worth. In our case for example, we have to deploy a Prometheus server to scrape metrics from other services (like KEDA, nginx, etc) and our collector scrapes that prometheus server to send the telemetry to the final backend (I know that collector can scrape the services directly, but it doesn't support Prometheus operator CRDs). If KEDA (and other services) supports OpenTelemetry Protocol, we can use it to send the metrics directly to the collector and route them from there as we want

JorTurFer avatar Jul 06 '23 09:07 JorTurFer

💯 - I'll get this on our roadmap to contribute from Microsoft side!

tomkerkhove avatar Jul 06 '23 11:07 tomkerkhove

Hi @tomkerkhove @JorTurFer ,

Here is my basic design for implementing this feature:

  1. Users can select their preferred metrics collection mode (Prometheus Only/OpenTelemetry Only/Prometheus and OpenTelemetry Both) using environment variables. The Keda operator will read these configuration settings (PROMETHEUS_ENABLE, OPENTELEMETRY_ENABLE, and OPENTELEMETRY_ENDPOINT).
  2. Refactor the current Prometheus.go file by adding a middleware struct, such as MetricLogger, to handle initialization and metrics collection for both Prometheus and OpenTelemetry.

Do you have any suggestions regarding this design?

SpiritZhou avatar Aug 01 '23 07:08 SpiritZhou

I agree with this implementation. It's more or less what I thought about it indeed. The only thing that I'd change is that instead of using new env vars for OTEL, I prefer to use the predefined variables when it's possible: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/

JorTurFer avatar Aug 01 '23 07:08 JorTurFer

I've found this exporter that we could use for exporting logs too: https://github.com/agoda-com/opentelemetry-go/tree/main/otelzap

JorTurFer avatar Oct 19 '23 13:10 JorTurFer