Page MenuHomeDevCentral

Serve ccache metrics and other utilities through api-exec
ClosedPublic

Authored by dereckson on Oct 7 2024, 00:16.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 7, 22:59
Unknown Object (File)
Sat, Dec 7, 16:58
Unknown Object (File)
Tue, Dec 3, 05:41
Unknown Object (File)
Tue, Dec 3, 05:41
Unknown Object (File)
Tue, Dec 3, 01:00
Unknown Object (File)
Tue, Dec 3, 01:00
Unknown Object (File)
Tue, Dec 3, 00:59
Unknown Object (File)
Tue, Dec 3, 00:59
Subscribers
None

Details

Summary

D3492 has introduced metrics for ccache as a command line utility.

That would have been enough in the 90s where cgi-bin was a reality,
but nowadays we don't even deploy Apache anymore.

This change solves this issue through api-exec, a tiny Flask
application to provide a request <> command gateway.

To reduce security issues, the gateway DOES NOT try to inject
URL parameters as shell arguments. It runs known commands and
arguments without any customization in the URL.

Ref T2039

Test Plan

Deployed on WindRiver.

Metrics for ccache available at http://172.27.27.35:2337/metrics/ccache

Diff Detail

Repository
rOPS Nasqueron Operations
Lint
Lint Passed
Unit
No Test Coverage
Branch
api-exec
Build Status
Buildable 5559
Build 5840: arc lint + arc unit

Event Timeline

dereckson created this revision.

Need to customize header to adhere to OpenMetrics specification.

That could solve the following issue when Prometheus queries the URL:

invalid metric type "info"
roles/devserver/api-exec/files/api-exec.conf
62

I wonder if we don't have to specify the OpenMetrics format through a specific header. RFC actually requires application/openmetrics-text

/metrics/ccache:
  command: ccache-metrics
  type: application/openmetrics-text
roles/devserver/api-exec/files/server.py
101

Per previous comment, a route can be:

  • a string to convert to {"command": "<value>", "type": "text/plain"}
  • a dictionary with command and type keys
115

I've put a live patch in WindRiver to use ccache-metrics with the correct header, Prometheus can then parse correctly the info type.

Allow to customize mime-type so we can serve application/openmetrics-text for metrics. Set PATH so /usr/local/bin is always in path, regardless how the service is launched.

At first uwsgi.yml and api-exec.conf was two separate files. So the difference of spacing. Let's use 2 spaces everywhere, per .editorconfig.

This revision is now accepted and ready to land.Oct 25 2024, 18:45