Yep!
version: v1.6
I kinda forget how my configuration file looks like, and forget to save it in a commit. but I’ll try my best to recall:
{
"analytics_storage_type": "redis",
"analytics_storage_config": {
"type": "redis",
"host": "redis",
"port": 6379,
"hosts": null,
"username": "",
"password": "",
"database": 0,
"optimisation_max_idle": 1000,
"optimisation_max_active": 2000,
"enable_cluster": false
},
"purge_delay": 10,
"pumps": {
"prometheus": {
"type": "prometheus",
"meta": {
"listen_address": ":9595",
"path": "/metrics",
"custom_metrics": [
{
"name": "tyk_http_tags_total",
"description": "Total of API requests with tags",
"metric_type": "counter",
"labels": [
"response_code",
"tags",
"path"
]
}
]
}
}
},
"dont_purge_uptime_data": true
}
And as I said in the previous conversation, I did a small change for pump to get a value from tags
:
// prometheus.go file ~line 330
// extract custom tags
tagMap := extractTags(decoded.Tags)
for _, label := range pm.Labels {
if val, ok := mapping[label]; ok {
values = append(values, fmt.Sprint(val))
} else {
// extract custom tags
if label == "x_apig_developerid" { // label must be set without "dash" since prom doesn't support it
if val, ok := tagMap["x-apig-developerid"]; ok {
values = append(values, fmt.Sprint(val))
} else {
values = append(values, fmt.Sprint(""))
}
}
}
}
return values
Other than that, cause custom metrics doesn’t support pump env variable configure (i assume), I also had another customized pump configured in the values.yaml.tpl
in helm-chart. (so it’s like… one pump configured in pump conf file as above, and another configured by env variable)