尊重作者的劳动,转载请注明作者及原文地址 http://www.cnblogs.com/txwsqk/p/6522854.html
参考 https://graphite.readthedocs.io/en/latest/functions.html#function-plugins
/opt/graphite/webapp/graphite/settings.py
# Function plugins FUNCTION_PLUGINS = ['linkedme.aliasByMap',]
/opt/graphite/webapp/graphite/functions/custom# ls __init__.py __init__.pyc linkedme.py linkedme.pyc
我添加了一个自定义函数 cat linkedme.py
#coding:utf-8 from graphite.functions.params import Param, ParamTypes def aliasByMap(requestContext, seriesList): kv = { '4000054':'你想展示的内容', } for series in seriesList: series.name = kv[series.name] return seriesList aliasByMap.group = 'Alias' aliasByMap.params = [ Param('seriesList', ParamTypes.seriesList, required=True), ] SeriesFunctions = { 'aliasByMap': aliasByMap, }
这样 grafana 中就可以使用了