infinityworks / prometheus-rancher-exporter

Exposes Rancher metrics to Prometheus
MIT License
99 stars 47 forks source link

Rename labels to be more consistent #31

Open marcbachmann opened 7 years ago

marcbachmann commented 7 years ago

Currently the rancher_stack_health_status and rancher_service_* metrics both have a name. In some cases it's a stack name and sometimes a service name.

It would be nice to have a more consistent naming of labels. I advise to rename the labels to stack_name and service_name. What do you think about that?

Here's how my metric relabel config looks like:

    metric_relabel_configs:
      - action: 'replace'
        source_labels: ['__name__', 'name']
        regex: 'rancher_stack_health_status;(.+)'
        target_label: 'stack_name'

      - action: 'replace'
        source_labels: ['__name__', 'name']
        regex: '(rancher_service_health_status|rancher_service_scale|rancher_service_state);(.+)'
        replacement: '$2'
        target_label: 'service_name'

      - action: 'replace'
        source_labels: ['__name__', 'exported_stack_name']
        regex: '(rancher_service_health_status|rancher_service_scale|rancher_service_state);(.+)'
        replacement: '$2'
        target_label: 'stack_name'

      - action: 'replace'
        source_labels: ['__name__']
        regex: 'rancher_service_[a-z_]*'
        replacement: ''
        target_label: 'exported_stack_name'

      - action: 'replace'
        source_labels: ['__name__']
        regex: '(rancher_stack_health_status|rancher_service_health_status|rancher_service_scale|rancher_service_state)'
        replacement: ''
        target_label: 'name'
Rucknar commented 7 years ago

Agree @marcbachmann something I only really appreciated once the exporter was published.

The problem we would have is that metric names have quite an impact when changed, this exporters had over 1m pulls on docker hub surprisingly so i'd be hesitant to introduce such a breaking change.

marcbachmann commented 7 years ago

Yeah, that would be a breaking change. What about making it configurable and log a deprecation message?

Rucknar commented 7 years ago

Fair point. Should get time to look at this next week, open to PR's of course.