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