简体   繁体   English

在Kairosdb中以json格式保存标记

[英]save tag in json format in Kairosdb

I'm learning KairosDB with Cassandra backend. 我正在用Cassandra后端学习KairosDB。 And I came across with the following issue: 我遇到了以下问题:

I'm trying to save metrics in the following fashion: 我正在尝试以下列方式保存指标:

    available_methods = json.dumps(available_methods)

    data = []
    for definition in archive_policy.definition:
        data.append({'name': '%s-archives' % metric,
                     'timestamp': time.time(),
                     'value': archive_policy.back_window,
                     'tags': {'metric': self._to_hex(metric),
                              'timespan': float(definition.timespan),
                              'granularity_points': '%s_%s' % (
                                  float(definition.granularity),
                                  definition.points),
                              'aggregation_methods': available_methods}})

And as a result, the metric isn't posted with all the importation, there is only name in it. 因此,度量标准不会随所有输入一起发布,其中只有名称。 I tried to post the metric with 'aggregation_methods' equal to string and and worked. 我尝试发布指标,其中'aggregation_methods'等于字符串,并且工作正常。

So, the question is: is it possible to save dict or json format in tags? 所以,问题是:是否可以在标签中保存dict或json格式?

For the record, I'm using pyKairosDB python client. 为了记录,我正在使用pyKairosDB python客户端。

thx 谢谢

actually not all characters are allowed in metric names and tag keys/values. 实际上,在度量标准名称和标记键/值中不允许所有字符。

cf. 比照 http://kairosdb.github.io/kairosdocs/FAQ.html#why-can-tags-only-handle-ascii-characters-and http://kairosdb.github.io/kairosdocs/FAQ.html#why-can-tags-only-handle-ascii-characters-and

This will evolve in future versions to become more permissive, but some particular character should remain forbidden are the column (:) and equals (=) because they is used as a field separator for constructing Cassandra Row key from tags and metric name. 这将在未来的版本中变得更加宽松,但是一些特定的字符应该保持禁止的是列(:)和等于(=),因为它们被用作字段分隔符,用于从标签和度量标准名称构造Cassandra Row密钥。

cf. 比照 http://kairosdb.github.io/kairosdocs/CassandraSchema.html http://kairosdb.github.io/kairosdocs/CassandraSchema.html

May I ask you why do you need to put a JSON object in a tag? 我可以问你为什么需要在标签中放置一个JSON对象?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 Python 字典保存为 JSON 格式(添加名称) - Save Python dictionary to the JSON format (adding names) PyQt5将QByteArray保存为json格式 - PyQt5 save QByteArray to json format 检索yum仓库并以json格式保存为列表 - Retrieve yum repos and save as list in json format 解析 HTML 并从标签的字符串中提取数据(JSON 格式) - Parse HTML and extract data from a tag's string (in JSON format) 将 API 响应(Json 格式)作为图像文件本地保存到系统 - Save the API response (Json format ) as image file locally to system 如何在不更改格式的情况下将“ for循环” json输出保存到变量? - How save the “for loop” json output to a variable without changing its format? 如何在python中循环字典并以JSON格式保存结果 - 格式无效 - How to Loop through a dictionary in python and save results in JSON format - invalid format 如何使用python将具有键值对的已抓取json数据保存为json文件格式 - How to save scraped json data with key value pair into a json file format using python 如何将循环字典从beautifulsoup4抓取结果保存为JSON文件格式? - How to save looping dictionary from beautifulsoup4 scraping result to JSON file format..? 使用 Python Pandas 保存到文件时如何正确格式化 JSON? - How to format JSON properly when I save to file using Python Pandas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM