graphite custom functions

尊重作者的劳动,转载请注明作者及原文地址 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 中就可以使用了

 

posted @ 2019-01-26 07:41  txwsqk  阅读(200)  评论(0编辑  收藏  举报