Created
August 3, 2016 09:31
-
-
Save zarnovican/f2b268ffe19c5a0a69d275ac3f81a34b to your computer and use it in GitHub Desktop.
telegraf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import json | |
import re | |
import sys | |
def snake_case(name): | |
name = name.replace('/', '_') | |
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) | |
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | |
j = json.load(sys.stdin) | |
for m in j['Metrics']: | |
print('cloudwatch_'+snake_case(m['Namespace']), end='') | |
d = [ snake_case(dim['Name'])+'='+dim['Value'] for dim in m['Dimensions'] ] | |
if len(d) > 0: | |
print(','+','.join(d), end='') | |
print(' ', end='') | |
print(snake_case(m['MetricName']+'_average')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment