Skip to content

Instantly share code, notes, and snippets.

@cesarandreu
Created March 7, 2017 02:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cesarandreu/568d40f96ee1844682974e2f6d0d6d76 to your computer and use it in GitHub Desktop.
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