Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,10 @@ scrape_configs:
```

`honor_labels: true` is important because exporter returns metrics with `instance` label set.

## Metrics

Exporter synthesizes [node_exporter](https://github.com/prometheus/node_exporter)-like metrics where possible.

You can see a list of basic monitoring metrics [there](https://github.com/percona/rds_exporter/blob/master/basic/testdata/all.txt)
and a list of enhanced monitoring metrics in text files [there](https://github.com/percona/rds_exporter/tree/master/enhanced/testdata).
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

7 changes: 3 additions & 4 deletions basic/metrics.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Code generated by go generate; DO NOT EDIT.
package basic

var Metrics = []Metric{
Expand Down Expand Up @@ -119,7 +118,7 @@ var Metrics = []Metric{
},
{
cwName: "EngineUptime",
prometheusName: "node_boot_time",
prometheusName: "node_boot_time_seconds",
prometheusHelp: "EngineUptime",
},
{
Expand All @@ -129,12 +128,12 @@ var Metrics = []Metric{
},
{
cwName: "FreeStorageSpace",
prometheusName: "node_filesystem_free",
prometheusName: "node_filesystem_free_bytes",
prometheusHelp: "The amount of available storage space. Units: Bytes",
},
{
cwName: "FreeableMemory",
prometheusName: "node_memory_Cached",
prometheusName: "node_memory_Cached_bytes",
prometheusHelp: "The amount of available random access memory. Units: Bytes",
},
{
Expand Down
28 changes: 14 additions & 14 deletions basic/testdata/all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,26 @@ aws_rds_write_latency_average{instance="autotest-psql-10",region="us-east-1"} 0.
aws_rds_write_throughput_average{instance="autotest-aurora-psql-11",region="us-west-2"} 606.8671102439675
aws_rds_write_throughput_average{instance="autotest-mysql-57",region="us-west-2"} 1.7282965432181072e+06
aws_rds_write_throughput_average{instance="autotest-psql-10",region="us-east-1"} 8942.486209022882
# HELP node_boot_time EngineUptime
# TYPE node_boot_time gauge
node_boot_time{instance="autotest-aurora-mysql-56",region="us-east-1"} 1.576149092e+09
node_boot_time{instance="autotest-aurora-psql-11",region="us-west-2"} 1.576147548e+09
# HELP node_boot_time_seconds EngineUptime
# TYPE node_boot_time_seconds gauge
node_boot_time_seconds{instance="autotest-aurora-mysql-56",region="us-east-1"} 1.576149092e+09
node_boot_time_seconds{instance="autotest-aurora-psql-11",region="us-west-2"} 1.576147548e+09
# HELP node_cpu_average The percentage of CPU utilization. Units: Percent
# TYPE node_cpu_average gauge
node_cpu_average{instance="autotest-aurora-mysql-56",region="us-east-1"} 5.67796610169553
node_cpu_average{instance="autotest-aurora-psql-11",region="us-west-2"} 4
node_cpu_average{instance="autotest-mysql-57",region="us-west-2"} 2.95081967213145
node_cpu_average{instance="autotest-psql-10",region="us-east-1"} 2.29508196721326
# HELP node_filesystem_free The amount of available storage space. Units: Bytes
# TYPE node_filesystem_free gauge
node_filesystem_free{instance="autotest-mysql-57",region="us-west-2"} 6.1639360512e+10
node_filesystem_free{instance="autotest-psql-10",region="us-east-1"} 6.1936873472e+10
# HELP node_memory_Cached The amount of available random access memory. Units: Bytes
# TYPE node_memory_Cached gauge
node_memory_Cached{instance="autotest-aurora-mysql-56",region="us-east-1"} 8.89040896e+08
node_memory_Cached{instance="autotest-aurora-psql-11",region="us-west-2"} 5.85375744e+08
node_memory_Cached{instance="autotest-mysql-57",region="us-west-2"} 8.6335488e+07
node_memory_Cached{instance="autotest-psql-10",region="us-east-1"} 5.24898304e+08
# HELP node_filesystem_free_bytes The amount of available storage space. Units: Bytes
# TYPE node_filesystem_free_bytes gauge
node_filesystem_free_bytes{instance="autotest-mysql-57",region="us-west-2"} 6.1639360512e+10
node_filesystem_free_bytes{instance="autotest-psql-10",region="us-east-1"} 6.1936873472e+10
# HELP node_memory_Cached_bytes The amount of available random access memory. Units: Bytes
# TYPE node_memory_Cached_bytes gauge
node_memory_Cached_bytes{instance="autotest-aurora-mysql-56",region="us-east-1"} 8.89040896e+08
node_memory_Cached_bytes{instance="autotest-aurora-psql-11",region="us-west-2"} 5.85375744e+08
node_memory_Cached_bytes{instance="autotest-mysql-57",region="us-west-2"} 8.6335488e+07
node_memory_Cached_bytes{instance="autotest-psql-10",region="us-east-1"} 5.24898304e+08
# HELP rds_exporter_scrape_duration_seconds Time this RDS scrape took, in seconds.
# TYPE rds_exporter_scrape_duration_seconds gauge
rds_exporter_scrape_duration_seconds 1.3998536129999999
4 changes: 3 additions & 1 deletion enhanced/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type processList struct {
TGID int `json:"tgid" help:"The thread group identifier, which is a number representing the process ID to which a thread belongs. This identifier is used to group threads from the same process."`
VSS int `json:"vss" help:"The amount of virtual memory allocated to the process, in kilobytes."`

// TODO Handle this.
// TODO Handle this: https://jira.percona.com/browse/PMM-5150

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enhanced/metrics.go:140: Line contains TODO/BUG/FIXME: "TODO Handle this: https://jira.percona.c..." (from godox)

VMLimit interface{} `json:"vmlimit" help:"-"`
}

Expand Down Expand Up @@ -466,6 +466,8 @@ func (m *osMetrics) makePrometheusMetrics(region string, labels map[string]strin
float64(m.Timestamp.Unix()),
))

// TODO Parse uptime: https://jira.percona.com/browse/PMM-2131

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enhanced/metrics.go:469: Line contains TODO/BUG/FIXME: "TODO Parse uptime: https://jira.percona...." (from godox)


res = append(res, prometheus.MustNewConstMetric(
prometheus.NewDesc("rdsosmetrics_General_numVCPUs", "The number of virtual CPUs for the DB instance.", nil, constLabels),
prometheus.GaugeValue,
Expand Down
31 changes: 24 additions & 7 deletions enhanced/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ import (
"github.com/percona/rds_exporter/sessions"
)

func filterMetrics(metrics []*helpers.Metric) []*helpers.Metric {
res := make([]*helpers.Metric, 0, len(metrics))
processList := make(map[string]struct{})

for _, m := range metrics {
m.Value = 0

// skip processList metrics that contain process IDs in labels that change too often
if strings.Contains(m.Name, "_processList_") {
if _, ok := processList[m.Name]; ok {
continue
}
processList[m.Name] = struct{}{}
}

res = append(res, m)
}
return res
}

func TestScraper(t *testing.T) {
cfg, err := config.Load("../config.tests.yml")
require.NoError(t, err)
Expand All @@ -36,15 +56,14 @@ func TestScraper(t *testing.T) {

for _, instance := range instances {
// Test that actually received JSON matches expected JSON.
// We can't do that directly, so we do it by comparing produced metrics (minus values).
// We can't do that directly, so we do it by comparing produced metrics
// (minus values and processList metrics).

instanceName := strings.TrimPrefix(instance.Instance, "autotest-")

actualMetrics := helpers.ReadMetrics(metrics[instance.ResourceID])
sort.Slice(actualMetrics, func(i, j int) bool { return actualMetrics[i].Less(actualMetrics[j]) })
for _, m := range actualMetrics {
m.Value = 0
}
actualMetrics = filterMetrics(actualMetrics)
actualLines := helpers.Format(helpers.WriteMetrics(actualMetrics))

if *golden {
Expand All @@ -55,9 +74,7 @@ func TestScraper(t *testing.T) {
require.NoError(t, err)
expectedMetrics := helpers.ReadMetrics(osMetrics.makePrometheusMetrics(instance.Region, nil))
sort.Slice(expectedMetrics, func(i, j int) bool { return expectedMetrics[i].Less(expectedMetrics[j]) })
for _, m := range expectedMetrics {
m.Value = 0
}
expectedMetrics = filterMetrics(expectedMetrics)
expectedLines := helpers.Format(helpers.WriteMetrics(expectedMetrics))

// compare both to try to avoid go-difflib bug
Expand Down