英文:
Project two or more columns with Prometheus metrics into one field and add characters between the values
问题
mssql_server_uptime_days
- >=0mssql_server_uptime_hours
- >=0 <24mssql_server_uptime_minutes
- >=0 <60
我有3个由sql_exporter生成的指标,显示相应的SQL实例运行时间部分。
我希望在Grafana中显示实例的总运行时间。最好的格式是 dd hh:mm
。
我尝试过使用"Concatenate fields" 转换来将它们连接在一起,但没有成功。
是否可以使用Prometheus作为数据源来完成这个任务?
附注:我知道可以查询数据库管理系统以轻松获取此结果。但我希望保持仪表板的单一数据源:Prometheus。
英文:
I have 3 metrics generated by sql_exporter that are showing corresponding SQL instance uptime part:
mssql_server_uptime_days
- >=0mssql_server_uptime_hours
- >=0 <24mssql_server_uptime_minutes
- >=0 <60
I'd like to show total uptime of instance in Grafana. Preferably in format dd hh:mm
.
I tried to concatenate them with the transformation Concatenate fields with no success.
Could it be done using Prometheus as data source?
P.S. I now that I can query DBMS to get this result easily. But I'd like not to, to keep single data source for this dashboard: Prometheus.
答案1
得分: 2
你可以将你的度量单位转换为秒:
mssql_server_uptime_days * 24 * 60 * 60 +
mssql_server_uptime_hours * 60 * 60 +
mssql_server_uptime_minutes * 60
并将列的单位设置为时间(标准选项 > 单位),使用 duration (d hh:mm:ss)
。
英文:
You can convert you metrics into value in seconds:
mssql_server_uptime_days * 24 * 60 * 60 +
mssql_server_uptime_hours * 60 * 60 +
mssql_server_uptime_minutes * 60
And set units of column (Standard options > Unit) to Time > duration (d hh:mm:ss)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论