Page MenuHomeDevCentral

Serve ccache metrics and other utilities through api-exec
Changes PlannedPublic

Authored by dereckson on Mon, Oct 7, 00:16.

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 5557
Build 5838: 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
61

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
100

Per previous comment, a route can be:

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

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