promethues监控信息获取
使用promethues官方提供的api获取监控信息 api/v1/query_range?query=%s&start=%s&end=%s&step=%ss
使用以上接口获得的json文件格式如下
{
"status":"success",
"data":{
"resultType":"matrix",
"result":[{
"metric": {"__name__":"node_context_switches_total",
"instance":"localhost:9100",
"job":"node"},
"values": [[1637204415,"73930819"],
[1637204430,"73938228"],
[1637204445,"73945017"],
[1637204460,"73951848"],
[1637204475,"73958661"]]
}]
}
}
type (
Values struct {
Timestamp int64
Value string
}
Metrics struct {
Name string `json:"name"`
Instance string `json:"instance"`
Job string `json:"job"