teralytics / prometheus-ecs-discovery

A Prometheus discoverer that scrapes Amazon ECS and a generates file SD configuration file.
Apache License 2.0
260 stars 157 forks source link

[feature request] add container/task labels to target labels #55

Open ZyanKLee opened 4 years ago

ZyanKLee commented 4 years ago

first things first: I love your work, thanks.

now to the feature request: We would like to filter the metrics based on various tags we attached to the AWS ECS TaskDefinition or the docker containers themselves. An example would be the environment name for example (we run several near-identical test environments in one test account and need to distinguish statistics between them).

I envision the target to look similar to this:

- targets:
  - 123.123.123.123:12345
  labels:
    task_arn: arn:aws:ecs:re-gion-1:1234567890:task/SomeTaskName/876535678765
    task_name: SomeTaskName
    job: OurJobName
    task_revision: "2"
    task_group: service:AwesomeServiceName-763456784
    cluster_arn: arn:aws:ecs:re-gion-1:1234567890:cluster/ClusterName
    container_name: main
    container_arn: arn:aws:ecs:re-gion-1:1234567890:container/09876543-12345678-09876543-123456789
    docker_image: image-name:v0.12.1
    docker_label_environment: test1
    docker_label_somethingelse: anothervalue
    task_tag_tagkey: tagvalue
    task_tag_environment: test1
    __metrics_path__: /metrics
Rudd-O commented 4 years ago

While in general it's inadvisable to create metrics that have unbounded label cardinality ( https://www.robustperception.io/cardinality-is-key ) — and I truly mean cardinality will kill your Prometheus hive — it's certainly possible to expand the data that is collected to it. I bow out and leave it to the kind people at Teralytics to decide if it's appropriate to add a command-line parameter or some other configuration mechanism to fulfil this need.

AnakinPt commented 3 years ago

I have the exact same need. For me is not the problem of cardinality because we don't have a huge amount of metrics, but we would like to distinguish them between environments.