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
F3751876: D3494.id8999.diff
Sun, Nov 17, 13:21
F3751571: D3494.id8999.diff
Sun, Nov 17, 10:28
F3751194: D3494.id.diff
Sun, Nov 17, 06:31
F3751158: D3494.diff
Sun, Nov 17, 06:02
F3751135: D3494.id9002.diff
Sun, Nov 17, 05:57
F3751057: D3494.id9155.diff
Sun, Nov 17, 05:37
F3751036: D3494.id9003.diff
Sun, Nov 17, 05:30
F3750974: D3494.diff
Sun, Nov 17, 05:05
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.Fri, Oct 25, 18:45