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
F3764459: D3494.id9000.diff
Fri, Nov 22, 05:56
F3764191: D3494.id8999.diff
Fri, Nov 22, 04:34
F3763209: D3494.diff
Thu, Nov 21, 21:45
Unknown Object (File)
Tue, Nov 19, 18:16
Unknown Object (File)
Tue, Nov 19, 17:49
Unknown Object (File)
Tue, Nov 19, 16:03
Unknown Object (File)
Tue, Nov 19, 15:58
Unknown Object (File)
Tue, Nov 19, 07:15
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 5556
Build 5837: 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.Fri, Oct 25, 18:45