Skip to content

Conversation

@cgagnaire
Copy link

Description

Adds a script to push metrics using the OpenTelemetry protocol on HTTP to a compatible backend.

The script respects the protocol as described in the following example:
https://github.com/open-telemetry/opentelemetry-proto/blob/main/examples/metrics.json

All metrics are considered gauge as per the data model.

Only the host.name resource attribute is added as a default. An enhancement could be to provide attributes as input from the configuration.

The configuration is thus simple:
image

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software

Target serie

  • 22.10.x
  • 23.04.x
  • 23.10.x
  • 24.04.x
  • 24.10.x
  • master

How this pull request can be tested ?

  1. Build yourself a Grafana LGTM stack,
  2. Configure your Broker to stream data to the Mimir/Prometheus otelhttp listener.

You should see logs like:

Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]: Loading event:
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    host: Host-Prod
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    metric: rtmin
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    point value: 0.0070000002160668
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    point time: 1751291066000000000
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]: Creating resource entry for host Host-Prod and metric rtmin
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]: Loading event:
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    host: Host-Prod
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    metric: rta
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    point value: 0.014000000432134
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    point time: 1751291066000000000
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]: Reusing resource entry for host Host-Prod and creating metric rta
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]: Loading event:
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    host: Host-Prod
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    metric: pl
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    point value: 0.0
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    point time: 1751291066000000000
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]: Reusing resource entry for host Host-Prod and creating metric pl
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]: Loading event:
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    host: Host-Prod
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    metric: rtmax
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    point value: 0.035000000149012
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]:    point time: 1751291066000000000
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:build_payload]: Reusing resource entry for host Host-Prod and creating metric rtmax
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:send_data]: Starting to send data
Mon Jun 30 15:44:30 2025: INFO: [sc_logger:log_curl_command]: curl command not logged because log_curl_commands param is set to: 0
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:send_data]: Going to send the following json {"resourceMetrics":[{"resource":{"attributes":[{"key":"host.name","value":{"stringValue":"Host-Prod"}}]},"scopeMetrics":[{"scope":{"name":"opentelemetry-otelhttp-json-metrics-apiv2.lua","version":"1.0.0"},"metrics":[{"name":"rtmin","gauge":{"dataPoints":[{"asDouble":0.0070000002160668,"timeUnixNano":"1751291066000000000"}]}},{"name":"rta","gauge":{"dataPoints":[{"asDouble":0.014000000432134,"timeUnixNano":"1751291066000000000"}]}},{"name":"pl","gauge":{"dataPoints":[{"asDouble":0.0,"timeUnixNano":"1751291066000000000"}]}},{"name":"rtmax","gauge":{"dataPoints":[{"asDouble":0.035000000149012,"timeUnixNano":"1751291066000000000"}]}}]}]}]}
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:send_data]: OpenTelemetry endpoint is: http://10.1.2.3:4319/v1/metrics
Mon Jun 30 15:44:30 2025: INFO: [EventQueue:send_data]: HTTP POST request successful: return code is 200

And you should find metrics like so in the drilldown:

streamconnector_otel_grafana

Checklist

Community contributors & Centreon team

  • I have followed the coding style guidelines provided by Centreon
  • I have commented my code, especially new classes, functions or any legacy code modified. (docblock)
  • I have commented my code, especially hard-to-understand areas of the PR.
  • I have rebased my development branch on the base branch (master, maintenance).

@cgagnaire cgagnaire requested a review from a team as a code owner June 30, 2025 14:37
@cgagnaire cgagnaire requested a review from tanguyvda June 30, 2025 14:37
@lucie-tirand
Copy link
Contributor

Hello :)

Your idea seems relevant, however we are initiating work to have an opentelemetry output directly in Broker so we don't plan to officially support a dedicated stream connector for it. Given that our work will take some time to release, we can integrate your stream connector directly into the community-powered part of our github repo of stream connectors. We thank you for your contribution and will integrate it as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants