在Graphite支持的Grafana中合并aliasByNode和aliasByMetric

时间:2016-07-09 11:22:17

标签: graphite grafana

我想按主机名+指标名称标注系列。我知道我可以使用public class ContributionView extends RelativeLayout implements Mappable<Resume.Contribution> { // Called from Constructors private void init(AttributeSet attrs, int defStyle) { root = (ViewGroup) LayoutInflater.from(getContext()).inflate( R.layout.internal_contribution_view, this, true); ... // Declare Navigation Accessibility Accessibility.with(root) // Disable certain views in the ViewGroup from ever gaining focus .disableFocusableNavigationOn( R.id.contribution_textview_creator, R.id.contribution_textview_year) // For all focusable views in the ViewGroup, set the D-pad Navigation .setFocusableNavigationOn(txtProjectName) .down(R.id.contribution_textview_description).complete() .setFocusableNavigationOn(txtContributionDescription) .up(R.id.contribution_textview_name) .down(R.id.contribution_textview_link).complete() .setFocusableNavigationOn(txtProjectLink) .up(R.id.project_textview_description).complete() // Set which view in the ViewGroup will have be first to be focused .requestFocusOn(R.id.contribution_textview_name); invalidateView(); } private void invalidateView() { ... // Declare Content Description Accessibility Accessibility.with(root) // Set the content descriptions for each focusable view in the ViewGroup // Set the content description for the Contribution Name .setAccessibilityTextOn(txtProjectName) .setModifiableContentDescription(getProjectName()) .prepend("Contribution occurred on the Project called ") .append(String.format(" by %s in %s", getProjectCreator(), getContributionYear())).complete() // Set the content description for the Contribution Description .setAccessibilityTextOn(txtContributionDescription) .setModifiableContentDescription(getContributionDescription()) .prepend("Description: ").complete() // Set the content description for the Contribution URL .setAccessibilityTextOn(txtProjectLink) .setModifiableContentDescription(getProjectLink()) .prepend("URL is ").complete(); } ... } 执行第一部分,aliasByNode(1)执行第二部分。任何想法如何在一个指标中合并这两个函数?

3 个答案:

答案 0 :(得分:12)

aliasByNode可以带有多个参数。

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "C:\Python35\lib\multiprocessing\pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
TypeError: func1() got multiple values for argument 'func'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:/DaweiLeng/Code/workspace/Python/General/theano_multiprocess_debug.py", line 36, in <module>
    Y = MPjob(xlist)
  File "F:/DaweiLeng/Code/workspace/Python/General/theano_multiprocess_debug.py", line 29, in MPjob
    for y in Results:
  File "C:\Python35\lib\multiprocessing\pool.py", line 695, in next
    raise value
TypeError: func1() got multiple values for argument 'func'

返回aliasByNode(apps.fakesite.web_server_01.counters.requests.count, 2,5)

Graphite的Grafana查询编辑器不支持此功能,但如果切换编辑模式,则可以编辑原始查询。编辑后,您可以切换回来。

Toggle Edit Mode

enter image description here

End Result

答案 1 :(得分:3)

您可能需要查看aliasSub,它允许您使用正则表达式替换来修改系列名称。

在grafana语法中,像aliasSub(([^.]+)([.][^.]+)*[.]([^.]+), \1 \3)这样的东西应该是你所追求的。

答案 2 :(得分:2)

解决所有这些问题的方法就是拥有一个包含指标节点替换参数的字符串,例如,

aliasByVars(&#34; core.app.city.rack.app.instance.thread&#34 ;,   &#34;资源:城市 - $ 3,机架 - $ 4&#34;)

您可以使用所需的度量元素(节点)的值来散布静态文本。

这可以用一个简单易懂的名称替换alias,aliasNode,aliasMetric和99%的aliasSub。

在某些aliasSub应用程序中,您使用了无法替换的部分节点名称。