prometheus.bats 862 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bats
  2. validate_metrics() {
  3. fname="${1}"
  4. params="${2}"
  5. curl -sS "http://localhost:19999/api/v1/allmetrics?format=prometheus&prefix=nd&timestamps=no${params}" |
  6. grep -E 'nd_system_|nd_cpu_|nd_system_|nd_net_|nd_disk_|nd_ip_|nd_ipv4_|nd_ipv6_|nd_mem_|nd_netdata_|nd_apps_|nd_services_' |
  7. sed -ne 's/{.*//p' | sort | uniq > tests/exportings/new-${fname}
  8. diff tests/exportings/${fname} tests/exportings/new-${fname}
  9. rm tests/exportings/new-${fname}
  10. }
  11. if [ ! -f .gitignore ]; then
  12. echo "Need to run as ./tests/exportings/$(basename "$0") from top level directory of git repository" >&2
  13. exit 1
  14. fi
  15. @test "prometheus raw" {
  16. validate_metrics prometheus-raw.txt "&data=raw"
  17. }
  18. @test "prometheus avg" {
  19. validate_metrics prometheus-avg.txt ""
  20. }
  21. @test "prometheus avg oldunits" {
  22. validate_metrics prometheus-avg-oldunits.txt "&oldunits=yes"
  23. }