<p>I’m looking for a way to differentiate between Prometheus metrics gathered from different dynamically discovered services running in a Kubernetes cluster (we’re using <a href="https://github.com/coreos/prometheus-operator" rel="nofollow noreferrer">https://github.com/coreos/prometheus-operator</a>). E.g. for the metrics written into the db, I would like to understand from which service they actually came.
I guess you can do this via a label from within the respective services, however, swagger-stats (<a href="http://swaggerstats.io/" rel="nofollow noreferrer">http://swaggerstats.io/</a>) which we’re using does not yet offer this functionality (to enhance this, there is an issue open: <a href="https://github.com/slanatech/swagger-stats/issues/50" rel="nofollow noreferrer">https://github.com/slanatech/swagger-stats/issues/50</a>). 
Is there a way to implement this over Prometheus itself, e.g. that Prometheus adds a service-specific label per time series after a scrape?</p>

<p>Appreciate your feedback! </p>

Florian
<blockquote>
  <p>Is there a way to implement this over Prometheus itself, e.g. that Prometheus adds a service-specific label per time series after a scrape?</p>
</blockquote>

<p>This is how Prometheus is designed to be used, as a target doesn't know how the monitoring system views it and prefixing metric names makes cross-service analysis harder. Both setting labels across an entire target and prefixing metric names are considered anti-patterns.</p>

<p>What you want is called a target label, these usually come from relabelling applied to metadata from service discovery.</p>

<p>When using the Prometheus Operator, you can specify <code>targetLabels</code> as a list of labels to copy from the Kubernetes Service to the Prometheus targets.</p>
