prom2json is a go module that can convert prometheus metrics to JSON. This could be useful for easy parsing of metrics for use in future op-mode commands:
Project page: https://github.com/prometheus/prom2json
JSON Output Example:
[
{
"name": "http_request_duration_microseconds",
"help": "The HTTP request latencies in microseconds.",
"type": "SUMMARY",
"metrics": [
{
"labels": {
"method": "get",
"handler": "prometheus",
"code": "200"
},
"quantiles": {
"0.99": "67542.292",
"0.9": "23902.678",
"0.5": "6865.718"
},
"count": "743",
"sum": "6936936.447000001"
},
{
"labels": {
"method": "get",
"handler": "prometheus",
"code": "400"
},
"quantiles": {
"0.99": "3542.9",
"0.9": "1202.3",
"0.5": "1002.8"
},
"count": "4",
"sum": "345.01"
}
]
},
{
"name": "roshi_select_call_count",
"help": "How many select calls have been made.",
"type": "COUNTER",
"metrics": [
{
"value": "1063110"
}
]
},
{
"name": "http_request_duration_seconds",
"type": "HISTOGRAM",
"help": "This is a native histogram.",
"metrics": [
{
"labels": {
"method": "GET",
},
"buckets": [
[
0,
"17.448123722644123",
"19.027313840043536",
"139"
],
[
0,
"19.027313840043536",
"20.749432874416154",
"85"
],
[
0,
"20.749432874416154",
"22.62741699796952",
"70"
],
],
"count": "1000",
"sum": "29969.50000000001"
}
]
},
{
"name": "some_weird_normal_distribution",
"type": "HISTOGRAM",
"help": "This is a classic histogram.",
"metrics": [
{
"buckets": {
"-0.0001899999999999998": "17",
"-0.0002899999999999998": "6",
"-0.0003899999999999998": "2",
"-0.0004899999999999998": "2",
"-0.0005899999999999998": "0",
"-0.0006899999999999999": "0",
"-0.0007899999999999999": "0",
"-0.00089": "0",
"-0.00099": "0",
"-8.999999999999979e-05": "33",
"0.00011000000000000022": "75",
"0.00021000000000000023": "92",
"0.0003100000000000002": "100",
"0.0004100000000000002": "103",
"0.0005100000000000003": "105",
"0.0006100000000000003": "106",
"0.0007100000000000003": "107",
"0.0008100000000000004": "107",
"0.0009100000000000004": "107",
"1.0000000000000216e-05": "50"
},
"count": "107",
"sum": "0.001792103516591124"
}
]
}
]