石墨中的自定义查询 [英] custom querying in graphite

查看:93
本文介绍了石墨中的自定义查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要收集有关多个服务器和业务流程的时间序列信息,并考虑使用石墨.如果我们要显示原始数据似乎很好.但是,如果我们想对此数据进行BI并运行自定义查询该怎么办?石墨允许吗?或者我可以指示石墨在事后信息中存储数据吗?

解决方案

Graphite绝对允许您以图形方式以图形方式查询数据并返回csv或json .石墨查询不是使用sql之类的语言完成的.它们是通过函数同时应用于一个指标来完成的.每个指标都是它自己的数据库,它只是一系列时间,值对.

您可能想要的最常见的事情是汇总不同时间段内的数据.下面是一个示例的网址示例,该示例的图形每天都会汇总一周的数据:

http://graphite.example.com/render/?width=586&height=308&_salt=1355992522.674&target=summarize(stats_counts.mystat.subname%2C%20'1day')&from=-7days

如果您想获取csv而不是图形,只需将format = json添加到网址中.而且,如果您通过石墨的Web界面查看数据,则只需输入以下内容即可查看相同的图形.

summarize(stats_counts.mystat.subname, '1day')

首先,您要做的大多数数据查询都将在石墨编辑器中进行,这只是一个Web界面,可让您单击要添加到图形的指标,然后将各种功能应用到它们. /p>

关于将数据添加到Postgres中,您可能不想这样做来查询数据.数据的结构并没有真正适合关系数据库.

We need to collect timeseries information on multiple server and business processes and consider to use graphite. It seems good if we want to display the raw data. But what if we want to do BI on this data and run custom queries? Does graphite allow that, or alternatively can I instruct graphite to store data on postgress?

解决方案

Graphite definitely allows you to query your data, both graphically and returning csv or json. The queries in graphite aren't done with a language like sql. They're done with functions that apply to one metric at a time. Each metric is it's own database, which is just a series of time, value pairs.

The most common thing you're likely to want is summarize data over different time periods. Here's an example of what the url would look like for a graph where the data is summarized daily for a week:

http://graphite.example.com/render/?width=586&height=308&_salt=1355992522.674&target=summarize(stats_counts.mystat.subname%2C%20'1day')&from=-7days

If you wanted to get back csv instead of a graph, you would just add format=json to the url. And if you're looking at the data through graphite's web interface you'd just be putting the following in to view the same graph.

summarize(stats_counts.mystat.subname, '1day')

Most of the querying of data you do will at first be in the graphite composer, which is just a web interface that lets you click on the metrics you want to add to the graph, and apply the various functions to them.

As for adding the data to Postgres, you're probably not going to want to do that to query it. The data isn't really structured in a way that's great for relational databases.

这篇关于石墨中的自定义查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆