英文:
Getting a start and stop time points of returning HTTP codes by HTTP endpoint, in Prometheus
问题
让我们假设我们有一天的时间范围 - 00:00 - 23:59,以及一个HTTP端点(由Blackbox-exporter探测),返回的状态码如下:
- 从00:00到7:00,端点返回200
- 然后从7:00到7:05返回500
- 然后从7:05到20:00返回200
- 然后从20:00到20:10返回404
- 从20:10到23:59返回200
我能否在Prometheus中以某种方式反映它,即当一个代码结束返回并另一个开始时?而且也许可以在Grafana上以时间范围图的方式输出?
(Note: The code parts have been omitted as requested.)
英文:
Let's assume we have a time range of day - 00:00 - 23:59 and HTTP endpoint(which is being probed by Blackbox-exporter) returns status codes:
- from 00:00 to 7:00 endpoint was returning 200
- then from 7:00 to 7:05 was returning 500
- then from 7:05 to 20:00 was returning 200
- then from 20:00 to 20:10 was returning 404
- and from 20:10 to 23:59 was returning 200
Can I reflect it somehow in Prometheus, i.e. when one code ends up being returned and another one started? And maybe it's possible to output somehow in Grafana on a time-range plot?
答案1
得分: 1
If all you want is just to visualize status code, you don't need some clever promQL query for this.
You can simply create "State timeline" panel with probe_http_status_code
query.
To make this panel show data in understandable way:
- Expand query options (under query), select Legend: Custom, and put
{{instance}}
into it. - Go to Panel options: Standard options > Color scheme > Single color.
- Value mappings: add HTTP codes with corresponding colors. You can make mappings single value or range based.
In the result you'll get something like this:
英文:
If all you want is just to visualize status code, you don't need some clever promQL query for this.
You can simply create "State timeline" panel with probe_http_status_code
query.
To make this panel show data in understandable way:
- Expand query options (under query), select Legend: Custom, and put
{{instance}}
into it. - Go to Panel options: Standard options > Color scheme > Single color.
- Value mappings: add HTTP codes with corresponding colors. You can make mappings single value or range based.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论