Prometheus is an open-source software project recording real-time metrics using HTTP pull model 1. Prometheus records metrics in a time series database and allows for high-dimensionality.
The promR
package offers Promethous
class that provides two methods of sourcing data via instant and range query. The package also facilitates sourcing of the relevant metadata. With use of the sample host, the Prometheus class can be created in the following manner.
The instant query sources the data for specific timestamp. The timestamp should be of class returned by as.POSIXct
.
# Timestamps can be in rfc3339 or unix format
metrics_instant <- prom$query(query = "go_goroutines",
time = as.POSIXct("2019-08-11 12:25:57 BST"))
name | instance | job | timestamp | value | port |
---|---|---|---|---|---|
go_goroutines | demo.robustperception.io | prometheus | 1565522757 | 295 | 9090 |
go_goroutines | demo.robustperception.io | pushgateway | 1565522757 | 122 | 9091 |
go_goroutines | demo.robustperception.io | alertmanager | 1565522757 | 36 | 9093 |
go_goroutines | demo.robustperception.io | node | 1565522757 | 9 | 9100 |
A range query permits sourcing of the data for a specific period according to a designated interval.
metrics_range <- prom$rangeQuery(
query = "go_goroutines",
start = as.numeric(as.POSIXct("2019-08-11 12:20:32 BST")),
end = as.numeric(as.POSIXct("2019-08-11 12:30:46 BST")),
step = "10s"
)
name | instance | job | port | timestamp | value |
---|---|---|---|---|---|
go_goroutines | demo.robustperception.io | prometheus | 9090 | 1565522432 | 301 |
go_goroutines | demo.robustperception.io | prometheus | 9090 | 1565522442 | 301 |
go_goroutines | demo.robustperception.io | prometheus | 9090 | 1565522452 | 301 |
go_goroutines | demo.robustperception.io | prometheus | 9090 | 1565522462 | 301 |
go_goroutines | demo.robustperception.io | prometheus | 9090 | 1565522472 | 301 |
go_goroutines | demo.robustperception.io | prometheus | 9090 | 1565522482 | 301 |
Metadata can be sourced using the metadataQuery
call.
metric | type | help | unit | instance | job |
---|---|---|---|---|---|
node_netstat_Udp_InErrors | unknown | Statistic UdpInErrors. | demo.robustperception.io:9100 | node | |
node_network_address_assign_type | gauge | address_assign_type value of /sys/class/net/ |
demo.robustperception.io:9100 | node | |
node_timex_tick_seconds | gauge | Seconds between clock ticks. | demo.robustperception.io:9100 | node | |
node_memory_SwapTotal_bytes | gauge | Memory information field SwapTotal_bytes. | demo.robustperception.io:9100 | node | |
node_network_dormant | gauge | dormant value of /sys/class/net/ |
demo.robustperception.io:9100 | node | |
node_vmstat_pswpin | unknown | /proc/vmstat information field pswpin. | demo.robustperception.io:9100 | node |
For a detailed overview of the project refer to the project website https://prometheus.io/.↩︎