You didn't say anything about where this list of targets is coming from.
If it's static, then very simply:
- job_name: blah
static_configs:
- targets:
- 1.2.3.4:9288
labels:
__metrics_path__: /perf-metrics
- targets:
- 1.2.3.4:9277
labels:
__metrics_path__: /auth-metrics
- targets:
- 1.2.3.4:9266
labels:
__metrics_path__: /app-metrics
Or being a bit fancier with target relabelling, something like this
(untested):
- job_name: blah
static_configs:
- targets:
- 1.2.3.4:9288/perf-metrics
- 1.2.3.4:9277/auth-metrics
- 1.2.3.4:9266/app-metrics
relabel_configs:
- source_labels: [__address__]
target_label: instance
- source_labels: [__address__]
regex: '([^/]+)(.*)'
target_label: __metrics_path__
replacement: '$2'
- source_labels: [__address__]
regex: '([^/]+)(.*)'
target_label: __address__
replacement: '$1'
If it's coming from some service discovery mechanism, then you can use
target rewriting rules to replace the __address__ label with <addr>:<port>
and __metrics_path__ with <path>, where <addr>, <port> and <path> come from
some data returned by the service discovery mechanism. For example, with
kubernetes SD you can access the label values and annotations on
nodes/pods/services in __meta_XXX labels.
On Monday, 7 March 2022 at 06:47:18 UTC Anoop wrote:
> Hi,
>
> Any suggestions?
>
> Thanks,
> Anoop
>
>
>
> On Fri, Mar 4, 2022 at 12:28 PM Anoop <[email protected]> wrote:
>
>> Hi,
>>
>> I have a kubernetes pod running with 3 containers in it. I am exporting
>> metrics to different port and path for each container. Is there any way to
>> enable monitoring for three ports and paths using a single service?
>>
>> prometheus.io/path: /perf-metrics
>> prometheus.io/scrape_port: '9288'
>>
>> prometheus.io/path: /auth-metrics
>> prometheus.io/scrape_port: '9277'
>>
>> prometheus.io/path: /app-metrics
>> prometheus.io/scrape_port: '9266'
>>
>> Thanks,
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Prometheus Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/prometheus-users/ca7ecdde-3efa-40ab-a5f1-62613a5ec742n%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/prometheus-users/ca7ecdde-3efa-40ab-a5f1-62613a5ec742n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/bf343662-e122-40a3-8840-3d44b10e8e57n%40googlegroups.com.