Created
March 7, 2017 02:51
-
-
Save cesarandreu/568d40f96ee1844682974e2f6d0d6d76 to your computer and use it in GitHub Desktop.
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
import { | |
cond, | |
conformsTo, | |
constant, | |
eq, | |
flow, | |
get, | |
matches, | |
replace, | |
startsWith, | |
stubTrue | |
} from 'lodash/fp' | |
import humanize from 'underscore.string.fp/humanize' | |
export const getMetricLabel = cond([ | |
[matches({ dataSource: 'node_data', metric: 'cpu:user' }), | |
constant('CPU (td-agent user)') | |
], | |
[matches({ dataSource: 'node_data', metric: 'cpu:system' }), | |
constant('CPU (system total)') | |
], | |
[matches({ dataSource: 'node_data', metric: 'cpu:loadavg1' }), | |
constant('CPU (average load)') | |
], | |
[conformsTo({ dataSource: eq('node_data'), metric: startsWith('disk:') }), | |
flow(get('metric'), replace('disk:', ''), (type) => `Disk Usage (${type})`) | |
], | |
[stubTrue, | |
flow(get('metric'), replace(':', ' '), humanize) | |
] | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment