graphite custom functions

尊重做者的勞動,轉載請註明做者及原文地址 http://www.cnblogs.com/txwsqk/p/6522854.html html

參考 https://graphite.readthedocs.io/en/latest/functions.html#function-pluginsweb

/opt/graphite/webapp/graphite/settings.py app

# Function plugins
FUNCTION_PLUGINS = ['linkedme.aliasByMap',]

 

/opt/graphite/webapp/graphite/functions/custom# ls
__init__.py  __init__.pyc  linkedme.py  linkedme.pyc

我添加了一個自定義函數  cat linkedme.pywebapp

#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 中就可使用了函數

相關文章
相關標籤/搜索