Code Monkey home page Code Monkey logo

atlas_exporter's Introduction

atlas_exporter

Go Report Card

Metric exporter for RIPE Atlas measurement results

Remarks

  • this is an early version, more features will be added step by step
  • at the moment only the last result of an measurement is used
  • the required Go version is 1.19+

Streaming API

Since version 0.8 atlas_exporter also supports retrieving measurement results by RIPE Atlas Streaming API (https://atlas.ripe.net/docs/result-streaming/). Using this feature requires config file mode. All configured measurements are subscribed on start so the latest result for each probe is updated continuously and scrape time is reduced significantly. When a socket.io connection fails or times out a reconnect is initiated. The timeout can be configured using the -streaming.timeout parameter. Streaming API is the default for config file mode, it can be disabled by setting -streaming to false.

Histograms

Since version 1.0 atlas_exporter provides you with histograms of round trip times of the following measurement types:

  • DNS
  • Ping
  • Traceroute
  • HTTP

The buckets can be configured in the config file (see below).

Since this feature relies strongly on getting each update for a measurement, the Stream API mode has to be used. Histogram metrics enables you to calculate percentiles for a specifiv indicator (in our case round trip time). This allows better monitoring of defined service level objectives (e.g. Ping RTT of a specific measurement should be under a specific threshold based on 90% of the requests disregarding the highest 10% -> p90).

For more information: https://prometheus.io/docs/practices/histograms/

Install

go get -u github.com/czerwonk/atlas_exporter

Docker

To start the server:

docker run -d --restart unless-stopped -p 9400:9400 czerwonk/atlas_exporter

To run in config file mode:

docker run -d -e CONFIG=/tmp/config.yml -v /tmp/config.yml:/tmp/config.yml --restart unless-stopped -p 9400:9400 czerwonk/atlas_exporter 

Usage

Start server

./atlas_exporter

or using config file mode:

./atlas_exporter -config.file config.yml

Config file

for this example we want to retrieve results for measurement 8772164

measurements:
  - id: 8772164
    timeout: 120s
histogram_buckets:
  ping:
    rtt:
      - 5.0
      - 10.0
      - 25.0
      - 50.0
      - 100.0
filter_invalid_results: true

Call metrics URI

when using config file mode:

curl http://127.0.0.1:9400/metrics

or ad hoc for measuremnt 8772164:

curl http://127.0.0.1:9400/metrics?measurement_id=8772164

in both cases the result should look similar to this one:

# HELP atlas_traceroute_hops Number of hops
# TYPE atlas_traceroute_hops gauge
atlas_traceroute_hops{asn="1101",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="6031"} 9
atlas_traceroute_hops{asn="11051",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="17833"} 8
atlas_traceroute_hops{asn="111",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="6231"} 9
atlas_traceroute_hops{asn="11427",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="1121"} 13
atlas_traceroute_hops{asn="12337",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="267"} 13
atlas_traceroute_hops{asn="1257",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="140"} 11
atlas_traceroute_hops{asn="12586",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="2088"} 13
atlas_traceroute_hops{asn="12597",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="2619"} 10
atlas_traceroute_hops{asn="12714",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="2684"} 9
atlas_traceroute_hops{asn="133752",dst_addr="8.8.8.8",dst_name="8.8.8.8",ip_version="4",measurement="8772164",probe="6191"} 14

...

Features

  • ping measurements (success, min/max/avg latency, dups, size)
  • traceroute measurements (success, hop count, rtt)
  • ntp (delay, derivation, ntp version)
  • dns (succress, rtt)
  • http (return code, rtt, http version, header size, body size)
  • sslcert (alert, rtt)

Prometheus configuration

Ad-Hoc Mode

  - job_name: 'atlas_exporter'
    scrape_interval: 5m
    static_configs:
      - targets:
        - 7924888
        - 7924886
    relabel_configs:
      - source_labels: [__address__]
        regex: (.*)(:80)?
        target_label: __param_measurement_id
        replacement: ${1}
      - source_labels: [__param_measurement_id]
        regex: (.*)
        target_label: instance
        replacement: ${1}
      - source_labels: []
        regex: .*
        target_label: __address__
        replacement: atlas-exporter.mytld:9400

Config Mode

  - job_name: 'atlas_exporter'
    scrape_interval: 5m
    static_configs:
      - targets:
          - atlas-exporter.mytld:9400

Third Party Components

This software uses components of the following projects

License

(c) Daniel Czerwonk, 2017. Licensed under LGPL3 license.

Prometheus

see https://prometheus.io/

The RIPE Atlas Project

see http://atlas.ripe.net

Further reading

I wrote an article about atlas_exporter for RIPE Labs. It covers version 0.5. https://labs.ripe.net/Members/daniel_czerwonk/using-ripe-atlas-measurement-results-in-prometheus-with-atlas_exporter

atlas_exporter's People

Contributors

czerwonk avatar dependabot[bot] avatar fdomain avatar glightfoot avatar mjtrangoni avatar nlamirault avatar snh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atlas_exporter's Issues

Metrics not displaying in end point?

When querying the end point with prometheus or through the URL it opens a white screen and no metrics are displayed. I've verified the exporter is running as a service and has permissions, also that the prometheus yml file is correct and pointing at the IP and port number. Is this just a Docker exporter? Or can it run outside of the Docker Environment?

Streaming timeout causes stale statistics

Thanks for your awesome project!

I have encountered strange issue caused by streaming API socket timeout that causes exporter to return stale statistics. Once I restart it manually, problem is solved.

For indexation purposes I will attach a few lines myself:

time="2024-05-07T18:51:41Z" level=info msg="Got result for xxx from probe y"
time="2024-05-07T18:53:41Z" level=error msg="Timeout reached for measurement #xxx. Trying to reconnect."
time="2024-05-07T18:56:02Z" level=info msg="Cleaning up cache..."
time="2024-05-07T18:56:02Z" level=info msg="Items removed: 0"
Details

image

logs.txt

DNS against local resolvers with ResultSet respojse does not recognise rtt correctly

While testing the exporter against some of my ongoing DNS test I noticed that the rtt value isn't recognised when the response contains multiple results in a resultset.

According to the ripe documentation;

resultset - [optional] an array of objects containing all the fields of a DNS result object, except for the fields: fw, from, msm_id, prb_id, and type. Available for queries sent to each local resolver.

This was added in version 4750.

Test ID as a reference: 16878571

Here's a lazy workaround that's super ugly, but i can't get the nicer version working (See later).

diff --git a/dns/exporter.go b/dns/exporter.go
index d7819ed..55e7bf5 100644
--- a/dns/exporter.go
+++ b/dns/exporter.go
@@ -41,8 +41,18 @@ func (m *dnsExporter) Export(res *measurement.Result, probe *probe.Probe, ch cha
        var rtt float64
        if res.DnsResult() != nil {
                rtt = res.DnsResult().Rt()
+               recordRtt(rtt, labelValues, ch)
+       } else if res.DnsResultsets() != nil {
+               for _, s := range res.DnsResultsets() {
+                       if s.Result() != nil {
+                               rtt = s.Result().Rt()
+                               recordRtt(rtt, labelValues, ch)
+                       }
+               }
        }
+}

+func recordRtt(rtt float64, labelValues []string, ch chan<- prometheus.Metric) {
        if rtt > 0 {
                ch <- prometheus.MustNewConstMetric(successDesc, prometheus.GaugeValue, 1, labelValues...)
                ch <- prometheus.MustNewConstMetric(rttDesc, prometheus.GaugeValue, rtt, labelValues...)

Non Working Workaround

I'd much prefer to do something like this, but I can't quite get my head around golangs slices/arrays pointers/references etc to make the popping of the first element off the DNSResultSets() array response not cause a segfault.

diff --git a/dns/exporter.go b/dns/exporter.go
index d7819ed..b6706d4 100644
--- a/dns/exporter.go
+++ b/dns/exporter.go
@@ -41,6 +41,8 @@ func (m *dnsExporter) Export(res *measurement.Result, probe *probe.Probe, ch cha
        var rtt float64
        if res.DnsResult() != nil {
                rtt = res.DnsResult().Rt()
+       } else if res.DnsResultsets() != nil {
+               rtt = res.DnsResultsets()[0].Result().Rt()
        }

        if rtt > 0 {

AS Lookup

Thanks for a fantastic app.

I read your RIPE Blog post that talked about AS-lookup and caching but I can't find any documentation around what is the intended data to be looked up? Is the purpose purely to include the ASN in the resulting prometheus data, or is the system supposed to pull other useful information such as the name of the network too?

ripe atlas exporter memory leak

Hello,

Thanks for the tool :)

Since the beginning of my use of the exporter, I could see the exporter using lots of memory until it gets OOM killed.
See screen attached:
memleak

It uses the RIPE streaming API for < 20 measurements.

I've been installing the exporter via go get or building it from master, same result.

Is there anything I can do to help tshoot this ?
Does anyone else is experiencing the same behavior ?

@++
Lodpp

ps: as a band-aid / workaround, I've added a daily cronjob to restart the exporter

Additional endpoint for probe location lookup

Hey Daniel,
great work. Your atlas_exporter is very useful and works great. Thanks for that.
I played around with grafana worldmap panel and was able to draw the metrics served by the exporter on the map. I took your code and added another endpoint to get the geometry data of the probes which are present in the cache.
I want to know what you think of this in general. Adding another endpoint makes the exporter serve more than just the metrics, but I think the advantage one can get from this feature would be very useful, as it automatically serves the probe data from a reliable source.

Thanks
Sebi

make build fails: failure in meikg/dns

I think i installed the requisite dependency packages, but this error is in a vendor/ package, so it came along for the ride :)

morrowc@build:~/atlas_exporter (master)$ make build
[atlas_exporter] Build

github.com/czerwonk/atlas_exporter/vendor/github.com/miekg/dns

../.go/src/github.com/czerwonk/atlas_exporter/vendor/github.com/miekg/dns/msg_helpers.go:144: base32.HexEncoding.WithPadding undefined (type *base32.Encoding has no field or method WithPadding)
../.go/src/github.com/czerwonk/atlas_exporter/vendor/github.com/miekg/dns/msg_helpers.go:144: undefined: base32.NoPadding
Makefile:55: recipe for target 'build' failed
make: *** [build] Error 2

note that at least current golang reports there is a 'WithPadding' method on an Encoding struct:
https://golang.org/src/encoding/base32/base32.go?s=569:650#L72

so I suspect something else is going on here, and perhaps just upgrading away to the newer version of miekg's dns package is the right path?

NSID inclusion

There was part of a pull request (24cfba9) that added NSID as part of the result. That would be really, really helpful for determining where these results came from for the DNS query sets. Can this be re-added?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.