Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize metrics #562

Merged
merged 4 commits into from
Jan 29, 2020
Merged

Sanitize metrics #562

merged 4 commits into from
Jan 29, 2020

Conversation

jakubdyszkiewicz
Copy link
Contributor

Summary

Prometheus

Convertion from statsd to prometheus breaks when we have clusters with dots.
Example:
statsd:

cluster.backend.kuma-demo.svc_3001.assignment_stale: 0

prometheus

envoy_cluster_kuma_demo_svc_3001_assignment_stale{envoy_cluster_name="backend"}

There were several ways to fix it.

  1. We could introduce ._. suffix to clusters so you can skip extra part on Statsd and then build proper regex for Prometheus.
  2. We can replace every . in cluster name with _.

We picked second solution since it's less error prone. So the metric with this fix looks like following:
statsd:

cluster.backend_kuma-demo_svc_3001.assignment_stale: 0

prometheus

envoy_cluster_assignment_stale{envoy_cluster_name="backend_kuma-demo_svc_3001"}

StatsD

We also have to sanitize metrics for StatsD as : and | chars are illegal.
Official func to sanitize metrics looks like this https://github.com/statsd/statsd/blob/master/stats.js#L167

I slightly modified it changing the illegal characters always to _.

Example files
fix_configdump.txt
fix_prometheus.txt
fix_statsd.txt

For the cluster name. Instead of changing the name in every place I leveraged alt_stat_name field. I think this is less error prone since we reference cluster names in many places in the config.

@jakubdyszkiewicz jakubdyszkiewicz requested review from yskopets and a team January 28, 2020 16:05
@jakubdyszkiewicz jakubdyszkiewicz merged commit f007f8d into master Jan 29, 2020
tharun208 pushed a commit to tharun208/kuma that referenced this pull request Feb 7, 2020
@jakubdyszkiewicz jakubdyszkiewicz deleted the fix/prometheus-metrics-k8s branch February 28, 2020 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants