# Collect Metrics from a Prometheus Endpoint Using a Dynatrace Custom Extension

**URL:** <https://community.dynatrace.com/t/collect-metrics-from-a-prometheus-endpoint-using-a-dynatrace-custom-extension/47560>\
**Category:** Extensions\
**Tags:** dynatrace-managed, prometheus, extensions\
**Created:** [September 10, 2024, 7:48am UTC](https://community.dynatrace.com/t/collect-metrics-from-a-prometheus-endpoint-using-a-dynatrace-custom-extension/47560 "2024-09-10T07:48:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KVL](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@KVL](https://community.dynatrace.com/u/KVL)\
**Post date:** [September 10, 2024, 7:48am UTC](https://community.dynatrace.com/t/collect-metrics-from-a-prometheus-endpoint-using-a-dynatrace-custom-extension/47560/1 "2024-09-10T07:48:05Z")

</div>

I have created a custom Prometheus extension that collects metrics from an endpoint.

The thing is, there’s over 100 metrics there and I don’t want to add every one of them manually to the json.

So my question is, is there a way to collect all metrics from an endpoint? Or at least all metrics starting with a specific prefix (most of them have the same prefix)?

I saw in this documentation&nbsp;[Prometheus data source reference — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/prometheus-extensions-reference#filters) that you can use “filter”, however it seems to be in a different section of the json, and not where the metrics are, and seems metrics still need to be added regardless, if I’m understanding correctly.

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [September 10, 2024, 9:17am UTC](https://community.dynatrace.com/t/collect-metrics-from-a-prometheus-endpoint-using-a-dynatrace-custom-extension/47560/2 "2024-09-10T09:17:14Z")

</div>

Extensions 2.0 must have metrics defined explicitly. Use the VS Code extension where you have [development assistance](https://developer.dynatrace.com/develop/dynatrace-extensions-vscode/development_assistance/#prometheus) which allows you to add the metrics automatically:

 ![Julius_Loman_0-1725959645106.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/4/8406475221c2cf605af68d378524ce0feda92b30.png)

Please follow the lightbulb icon for assistance.

Otherwise scraping all metrics by a filter is only available in k8s environments where the Dynatrace Operator can scrape metrics from Prometheus exporters in your application pods.

---

<div class="post-metadata">

**Author:** ![danijela](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@danijela](https://community.dynatrace.com/u/danijela)\
**Post date:** [February 20, 2025, 1:03pm UTC](https://community.dynatrace.com/t/collect-metrics-from-a-prometheus-endpoint-using-a-dynatrace-custom-extension/47560/3 "2025-02-20T13:03:23Z")

</div>

Were you able to get the labels from the Prometheus metrics?
