Skip to content

Commit

Permalink
PMM-5058 Update node_exporter-like metrics. (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi authored Dec 11, 2019
1 parent 80355c9 commit 03bab8a
Show file tree
Hide file tree
Showing 15 changed files with 4,013 additions and 1,633 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ env:
global:
# AWS - PMM Autotest account. TODO https://jira.percona.com/browse/PMM-4896
# Travis secrets are not exposed to pull requests from forks: https://docs.travis-ci.com/user/pull-requests#pull-requests-and-security-restrictions
- AWS_ACCESS_KEY=AKIAZPBRO3QWINUW4BHY
- secure: "cIBRl4mgANxn6XPIO2SODBuNiLMraqH7yJ21vMmLUpjPxEsTGTUtlhNU/fBcb7F62SXsV3MgyahslhCU/62SyQccuICzkP4V9gtfE8GCSG4upWA5ka1CwWPFNCTQz0xU01oXkNe9V4WLbe0cRYlR4SI0b4TRZrYy5pt4WkBKEXDBn3RYqCcNEFjL9sPYTMOZKGc1mYtIJHNjwEYtv+7rAm0YRvvPmQnVeMXK2uZZcvmhxhHJfqUuKJYeyuC7CtTVh3QKdm7FpmXFVmFRFpcEQNqBwEE6W2mWnByKt/P8seBkcuVsYWAHDtN9JmbCN7/VhVm4pb/sFHuAJ3lm4PM9Q15r7GVmwEurVhNsi9S0oai/n4tbC9U63HPKLcq04UeXYp/K6tv6uGBL7+GTfFLnkG+YsM3Npj+O4NozTniX9vvvd3irbgXl8B5LzTz+/ypv4DV69eweoG1+xlME7iOrBMz/lQPDB9lIn8P9KEAiKpnnBbjJulBLVcG8j3WUqRw8rQFQA94UfqWL3g5FBxkQXoNNoRxFz0lXUA2nPw2maxQBThs4Awzg/yhm15ipAE49/wefLf+ZnEyfhOUHkQTzb7lj3RN7Mh7lfj7l6XR8YnHIkzWXXTp2sfVoDqQIVV2jRr4uBNOGIoXzXn6QEvxjy5ou0MlBbivU6usL7i0Y+yE="
- AWS_ACCESS_KEY=AKIAZPBRO3QWKASXOQEZ
- secure: "ZsqWjlnthwiHrMCytHeYLzC6pasDzBYZAL4vPdx7+viGiahIoYDeN+FkoXASYP4Z9RachE3GKquXeTPKCjAJ0elvYKHe1PC6+BsZrQWVOIMMqa1vMOuPVAMk7ohDsE4JqzjxdWYAErxE/GgcE7+7F/s79d+x+zpg0c0DVkNiprFWYnz2liKX0Ya926anDUAfT1fsHfSjDETufrNs06jfNMroFbEN22ebxiKL8Xbip6f3fY2SEasmiQ5MhmjMreDTY1zemnTvsaMNzjzSou3z+zqV6Z/Xt/FrS4t42vmo37w9wLYUlREPR0FJ6Z+c5PI4l/+RdBKQfvlilZDIq60ZeF3uHE2tVlSMXaOtNS7EVO9vJjxWb2qSLWeh8kmGsT87sBocUVILFG3ibmnbPiGtW4rDxqgtYPnAaxDU8yQL72K1EDkuJytQIXXDefHZ/FA5/+UTzv3cCIF2OviIVx2oEHrnkbq+YPvyjLGzp+eg8/In8m5Mc63UoepknLvlz5JrUKYePj2IUuyI2Dvl7+O4qm5o+SvNutoeYJYsWrKkPiaDXfAJ+J4QMerO2qbF2AWCQHHfeTRK8Sn6geK0ZK8SXEVeIty5IA95Bt/pBZJ4ZCn8ehK3nvepLOwhy/gGyejrjMlG9rcAvAyvnSN8aT1cHJJaKkAlF22chLVQ1pIcukE="

script:
- make travis
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ Create configration file `config.yml`:
```yaml
---
instances:
- instance: rds-aurora1
region: us-east-1
- instance: rds-mysql57
region: us-east-1
- region: us-east-1
instance: rds-aurora1

- region: us-east-1
instance: rds-mysql57
aws_access_key: AKIAIOSFODNN7EXAMPLE
aws_secret_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
labels:
Expand Down
2 changes: 1 addition & 1 deletion basic/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func getCollector(t *testing.T) *Collector {
t.Helper()

cfg, err := config.Load("../config.yml")
cfg, err := config.Load("../config.tests.yml")
require.NoError(t, err)
client := client.New()
sess, err := sessions.New(cfg.Instances, client.HTTP(), false)
Expand Down
12 changes: 12 additions & 0 deletions config.tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
# Shared configuration for all tests.

instances:
- region: us-east-1
instance: rds-aurora1
- region: us-east-1
instance: rds-aurora57
- region: us-east-1
instance: rds-mysql56
- region: us-west-1
instance: rds-mysql57
48 changes: 24 additions & 24 deletions enhanced/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ type loadAverageMinute struct {

//nolint:lll
type memory struct {
Active int `json:"active" node:"Active" m:"1024" help:"The amount of assigned memory, in kilobytes."`
Buffers int `json:"buffers" node:"Buffers" m:"1024" help:"The amount of memory used for buffering I/O requests prior to writing to the storage device, in kilobytes."`
Cached int `json:"cached" node:"Cached" m:"1024" help:"The amount of memory used for caching file system–based I/O."`
Dirty int `json:"dirty" node:"Dirty" m:"1024" help:"The amount of memory pages in RAM that have been modified but not written to their related data block in storage, in kilobytes."`
Free int `json:"free" node:"MemFree" m:"1024" help:"The amount of unassigned memory, in kilobytes."`
HugePagesFree int `json:"hugePagesFree" node:"HugePages_Free" m:"1" help:"The number of free huge pages. Huge pages are a feature of the Linux kernel."`
HugePagesRsvd int `json:"hugePagesRsvd" node:"HugePages_Rsvd" m:"1" help:"The number of committed huge pages."`
HugePagesSize int `json:"hugePagesSize" node:"Hugepagesize" m:"1024" help:"The size for each huge pages unit, in kilobytes."`
HugePagesSurp int `json:"hugePagesSurp" node:"HugePages_Surp" m:"1" help:"The number of available surplus huge pages over the total."`
HugePagesTotal int `json:"hugePagesTotal" node:"HugePages_Total" m:"1" help:"The total number of huge pages for the system."`
Inactive int `json:"inactive" node:"Inactive" m:"1024" help:"The amount of least-frequently used memory pages, in kilobytes."`
Mapped int `json:"mapped" node:"Mapped" m:"1024" help:"The total amount of file-system contents that is memory mapped inside a process address space, in kilobytes."`
PageTables int `json:"pageTables" node:"PageTables" m:"1024" help:"The amount of memory used by page tables, in kilobytes."`
Slab int `json:"slab" node:"Slab" m:"1024" help:"The amount of reusable kernel data structures, in kilobytes."`
Total int `json:"total" node:"MemTotal" m:"1024" help:"The total amount of memory, in kilobytes."`
Writeback int `json:"writeback" node:"Writeback" m:"1024" help:"The amount of dirty pages in RAM that are still being written to the backing storage, in kilobytes."`
Active int `json:"active" node:"Active_bytes" m:"1024" help:"The amount of assigned memory, in kilobytes."`
Buffers int `json:"buffers" node:"Buffers_bytes" m:"1024" help:"The amount of memory used for buffering I/O requests prior to writing to the storage device, in kilobytes."`
Cached int `json:"cached" node:"Cached_bytes" m:"1024" help:"The amount of memory used for caching file system–based I/O."`
Dirty int `json:"dirty" node:"Dirty_bytes" m:"1024" help:"The amount of memory pages in RAM that have been modified but not written to their related data block in storage, in kilobytes."`
Free int `json:"free" node:"MemFree_bytes" m:"1024" help:"The amount of unassigned memory, in kilobytes."`
HugePagesFree int `json:"hugePagesFree" node:"HugePages_Free" m:"1" help:"The number of free huge pages. Huge pages are a feature of the Linux kernel."`
HugePagesRsvd int `json:"hugePagesRsvd" node:"HugePages_Rsvd" m:"1" help:"The number of committed huge pages."`
HugePagesSize int `json:"hugePagesSize" node:"Hugepagesize_bytes" m:"1024" help:"The size for each huge pages unit, in kilobytes."`
HugePagesSurp int `json:"hugePagesSurp" node:"HugePages_Surp" m:"1" help:"The number of available surplus huge pages over the total."`
HugePagesTotal int `json:"hugePagesTotal" node:"HugePages_Total" m:"1" help:"The total number of huge pages for the system."`
Inactive int `json:"inactive" node:"Inactive_bytes" m:"1024" help:"The amount of least-frequently used memory pages, in kilobytes."`
Mapped int `json:"mapped" node:"Mapped_bytes" m:"1024" help:"The total amount of file-system contents that is memory mapped inside a process address space, in kilobytes."`
PageTables int `json:"pageTables" node:"PageTables_bytes" m:"1024" help:"The amount of memory used by page tables, in kilobytes."`
Slab int `json:"slab" node:"Slab_bytes" m:"1024" help:"The amount of reusable kernel data structures, in kilobytes."`
Total int `json:"total" node:"MemTotal_bytes" m:"1024" help:"The total amount of memory, in kilobytes."`
Writeback int `json:"writeback" node:"Writeback_bytes" m:"1024" help:"The amount of dirty pages in RAM that are still being written to the backing storage, in kilobytes."`
}

type network struct {
Expand All @@ -136,9 +136,9 @@ type processList struct {

//nolint:lll
type swap struct {
Cached float64 `json:"cached" node:"node_memory_SwapCached" m:"1024" help:"The amount of swap memory, in kilobytes, used as cache memory." nodehelp:"Memory information field SwapCached."`
Free float64 `json:"free" node:"node_memory_SwapFree" m:"1024" help:"The total amount of swap memory free, in kilobytes." nodehelp:"Memory information field SwapFree."`
Total float64 `json:"total" node:"node_memory_SwapTotal" m:"1024" help:"The total amount of swap memory available, in kilobytes." nodehelp:"Memory information field SwapTotal."`
Cached float64 `json:"cached" node:"node_memory_SwapCached_bytes" m:"1024" help:"The amount of swap memory, in kilobytes, used as cache memory." nodehelp:"Memory information field SwapCached."`
Free float64 `json:"free" node:"node_memory_SwapFree_bytes" m:"1024" help:"The total amount of swap memory free, in kilobytes." nodehelp:"Memory information field SwapFree."`
Total float64 `json:"total" node:"node_memory_SwapTotal_bytes" m:"1024" help:"The total amount of swap memory available, in kilobytes." nodehelp:"Memory information field SwapTotal."`

// we use multiplier 0.25 to convert a number of kilobytes to a number of 4k pages (what our dashboards assume)
In float64 `json:"in" node:"node_vmstat_pswpin" m:"0.25" help:"The total amount of memory, in kilobytes, swapped in from disk." nodehelp:"/proc/vmstat information field pswpin"`
Expand Down Expand Up @@ -259,12 +259,12 @@ func makeNodeDiskMetrics(s *diskIO, constLabels prometheus.Labels) []prometheus.
res := make([]prometheus.Metric, 0, 2)

if s.ReadKb != nil {
desc := prometheus.NewDesc("node_disk_bytes_read", "The total number of bytes read successfully.", labelKeys, constLabels)
desc := prometheus.NewDesc("node_disk_read_bytes_total", "The total number of bytes read successfully.", labelKeys, constLabels)
m := prometheus.MustNewConstMetric(desc, prometheus.CounterValue, float64(*s.ReadKb*1024), labelValues...)
res = append(res, m)
}
if s.WriteKb != nil {
desc := prometheus.NewDesc("node_disk_bytes_written", "The total number of bytes written successfully.", labelKeys, constLabels)
desc := prometheus.NewDesc("node_disk_written_bytes_total", "The total number of bytes written successfully.", labelKeys, constLabels)
m := prometheus.MustNewConstMetric(desc, prometheus.CounterValue, float64(*s.WriteKb*1024), labelValues...)
res = append(res, m)
}
Expand Down Expand Up @@ -310,11 +310,11 @@ func makeNodeFilesystemMetrics(s *fileSys, constLabels prometheus.Labels) []prom
res = append(res, prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, float64((s.MaxFiles-s.UsedFiles)*1024), labelValues...))

// report the same value for node_filesystem_free and node_filesystem_avail because we use both metrics in our dashboards
desc = prometheus.NewDesc("node_filesystem_size", "Filesystem size in bytes.", labelKeys, constLabels)
desc = prometheus.NewDesc("node_filesystem_size_bytes", "Filesystem size in bytes.", labelKeys, constLabels)
res = append(res, prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, float64(s.Total*1024), labelValues...))
desc = prometheus.NewDesc("node_filesystem_free", "Filesystem free space in bytes.", labelKeys, constLabels)
desc = prometheus.NewDesc("node_filesystem_free_bytes", "Filesystem free space in bytes.", labelKeys, constLabels)
res = append(res, prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, float64((s.Total-s.Used)*1024), labelValues...))
desc = prometheus.NewDesc("node_filesystem_avail", "Filesystem space available to non-root users in bytes.", labelKeys, constLabels)
desc = prometheus.NewDesc("node_filesystem_avail_bytes", "Filesystem space available to non-root users in bytes.", labelKeys, constLabels)
res = append(res, prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, float64((s.Total-s.Used)*1024), labelValues...))

return res
Expand Down
Loading

0 comments on commit 03bab8a

Please sign in to comment.