<p>Found this solution:</p>
<pre><code>static_configs:
  - targets: ['monitoring.api.endpoint.net']
metric_relabel_configs:
- source_labels: [__name__]
  regex: '(.*)'
  replacement: 'compute_${1}'
  target_label: __name__      
</code></pre>

CC BY-SA 4.0
2020-08-18T13:11:02.230Z
2020-08-18T13:11:02.230Z
Vasiliy  Shakhunov
<p>I have static config in prometheus.yml</p>
<pre><code>  - job_name: 'myjob'
    static_configs:
      - targets: ['monitoring.api.endpoint.net']
</code></pre>
<p>And I recieve various metrics for example <code>cpu_usage</code>, <code>disk_write_ops</code>, etc. Is it possible to put them all into namespace like <code>compute_cpu_usage</code> with relabel tool?</p>

<prometheus>
How to append namespace before metric name in prometheus?
Vasiliy  Shakhunov
# How to append namespace before metric name in prometheus?

(Asked by: username_0 on 2020-08-18)

I have static config in prometheus.yml
  - job_name: 'myjob'
    static_configs:
      - targets: ['monitoring.api.endpoint.net']

And I recieve various metrics for example cpu_usage, disk_write_ops, etc. Is it possible to put them all into namespace like compute_cpu_usage with relabel tool?

**Tags:** prometheus


---

## 1 answers

### Answer by username_0 on 2020-08-18. Score: 1 | Accepted answer

Found this solution:
static_configs:
  - targets: ['monitoring.api.endpoint.net']
metric_relabel_configs:
- source_labels: [__name__]
  regex: '(.*)'
  replacement: 'compute_${1}'
  target_label: __name__


---

