Skip to content

Conversation

@oryband
Copy link

@oryband oryband commented Jun 27, 2016

Add datadogMetricTagsByRegExp configuration,
which receives an object of { RegExpString: [TagNameString1, TagNameString2] }
where each tag name corresponds to a capture group in the regular expression.

For example:

datadogMetricTagsByRegExp: {
  '^interface\\.([\\w\\-]+?)\\.[\\w\\-]+?\\.[\\w\\-]+?\\.[\\w\\-]+?$': ['interface_name'],
  '^cpu\\.(\\d+)\\.cpu\\.(\\w+)$': ['cpu_cpu', 'cpu_time'],
  '^tcpconns\\.([\\w-]+)\\.tcp_connections\\.([\\w-]+)$': ['tcpconns_port', 'tcpconns_state'],
  '^load\\.load\\.([\\w-]+)$': ['load_term'],
  '^memory\\.memory\\.([\\w-]+)$': ['memory_type'],
  '^df\\.([\\w-]+?)\\.(?:\\w+?\\.)+([\\w-]+)$': ['df_partition', 'df_type'],
}

NOTE the strings will be read as a RegExp object, thus backslashes must be escaped.

The captured groups will be extracted and removed from the metric name and be
reported as datadog tags along with the metric e.g.

'interface.br-e5f9ab1037e7.if_packets.packets.tx' will be transformed into
'interface.if_packets.packets.tx|#interface_name:br-e5f9ab1037e7'

This allows for adding tag dimensions to untagged (e.g. collectd) metrics.

@oryband
Copy link
Author

oryband commented Jun 27, 2016

This PR can also be used to achieve the same feature as in #7

@oryband
Copy link
Author

oryband commented Jun 27, 2016

Also, I tried to be consistent with the style of the rest of the code - even though it can be improved. However, this is out of the scope of this PR.

@oryband oryband force-pushed the metric-parts-to-tags branch from fac79a0 to d9aaa3a Compare June 29, 2016 10:52
@oryband
Copy link
Author

oryband commented Jun 29, 2016

Updated the regexps to be more precise

@oryband oryband force-pushed the metric-parts-to-tags branch from d9aaa3a to 2ba47cb Compare June 29, 2016 10:54
Add 'datadogMetricTagsByRegExp' configuration,
which receives an object of { RegExpString: [TagNameString1, TagNameString2] }
where each tag name corresponds to a capture group in the regular expression.

For example:

datadogMetricTagsByRegExp: {
  '^interface\\.(\\S+)\\.(?:if_packets\\.packets|if_octets\\.octets|if_errors\\.errors)\\.(?:rx|tx)$': ['interface_name'],
  '^cpu\\.(\\d+)\\.cpu\\.(user|system|wait|idle|steal|nice|interrupt|softirq)$': ['cpu_cpu', 'cpu_time'],
  '^tcpconns\\.(\\S+)\\.tcp_connections\\.(ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT2|TIME_WAIT|CLOSED|CLOSED_WAIT|LAST_ACK|LISTEN|CLOSING)$': ['tcpconns_port', 'tcpconns_state'],
  '^load\\.load\\.(shortterm|midterm|longterm)$': ['load_term'],
  '^memory\\.memory\\.(cached|buffered|free|slab_recl|slab_unrecl|used)$': ['memory_type'],
  '^df\\.(\\S+)+\\.df_complex\\.(free|reserved|used)$': ['df_partition', 'df_type'],
}

NOTE the strings will be read as a RegExp object, thus backslashes must be escaped.

The captured groups will be extracted and removed from the metric name and be
reported as datadog tags along with the metric e.g.

'interface.br-e5f9ab1037e7.if_packets.packets.tx' will be transformed into
'interface.if_packets.packets.tx|#interface_name:br-e5f9ab1037e7'

This allows for adding tag dimensions to untagged (e.g. collectd) metrics.
@oryband oryband force-pushed the metric-parts-to-tags branch from 2ba47cb to 5fe2a23 Compare June 29, 2016 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant