【问题标题】:How to associate hash-named .wsp files to my tagged graphite metrics?如何将哈希命名的 .wsp 文件与我标记的石墨指标相关联?
【发布时间】:2023-09-12 13:10:01
【问题描述】:

我在 grafana 和 Whisper 上使用了石墨标记的指标,但 http://graphite/tags/delSeries 删除了一些内容,但没有删除 .wsp 文件。
未标记的指标会在具有人类可读名称的 Whisper 数据文件夹中创建 .wsp 文件,但已标记的指标仅在 _tagged 目录中创建以哈希命名的文件夹和 .wsp 文件。
像这样:

/whisper
  /data
    /Players
      registrations.wsp
      today_registrations.wsp
    /Gaming
      playing_count.wsp
    /_tagged
      /f58
        /010
          f58010d4cef67599a31f4daaab4a53c4d7fd85a9faea546282d2058c40c7e7b9.wsp
      /f56
        /031
          f56031052aec89dc9cc38e44dbe71b2eb08fb513a3e60d515eb1dc23f5b929d1.wsp

如何知道与我的标记指标关联的 .wsp 文件?

【问题讨论】:

    标签: grafana graphite whisper


    【解决方案1】:

    我也遇到了这个问题,如何将实际路径/标签度量映射到其对应的散列 wsp 文件。
    我认为您不能从哈希中计算出实际的指标名称,但您可以通过使用石墨的编码方法来做相反的事情。

    我已经快速编写了一个仅用于实验室目的的 Python 脚本:
    - 它可以在参数中使用多个度量名称并返回一个映射

    只需登录您的石墨主机并在 /opt/graphite/webapp/graphite/tags 中创建一个 python 脚本

    #!/opt/graphite/bin/python3
    
    import sys
    from utils import TaggedSeries
    
    for line in sys.stdin:
        paths = line.split()
        for path in paths:
            # Normalize first
            parsed = TaggedSeries.parse(path)
            print(  path + " -> /opt/graphite/storage/whisper/" + TaggedSeries.encode(parsed.path,'/',True) + ".wsp")
    

    然后您可以通过管道传输指标列表:

    #  echo "users.count;server=s1" |python mapper.py
    users.count;server=s1 -> /opt/graphite/storage/whisper/_tagged/b6c/c91/b6cc916d608e4b145b318669606e79118cc41d316f96735dd43621db4fd2bcaf.wsp
    

    您还可以获取所有标记的指标并生成一个文件,您可以稍后将其添加到脚本中。在此示例中,我获取与标签“服务器”关联的所有指标:

    # curl -s "http://localhost/tags/findSeries?expr=server=~." | sed s/"\", \""/\\n/g > my_metrics
    

    然后收集你的指标:

    # cat my_metrics | python mapper.py
    

    这是一个起点。从那里您可以轻松地编写一些简单的脚本来删除 wsp 文件,例如一个月以来未更新的文件。

    【讨论】:

      最近更新 更多