All Projects → gree-gorey → geoip-exporter

gree-gorey / geoip-exporter

Licence: Apache-2.0 License
GeoIP exporter for Prometheus

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to geoip-exporter

Druid Exporter
A Golang based exporter captures druid API related metrics and receives druid-emitting HTTP JSON data.
Stars: ✭ 54 (+100%)
Mutual labels:  exporter, prometheus, prometheus-exporter
Kminion
KMinion is a feature-rich Prometheus exporter for Apache Kafka written in Go. It is lightweight and highly configurable so that it will meet your requirements.
Stars: ✭ 274 (+914.81%)
Mutual labels:  exporter, prometheus, prometheus-exporter
Exporterhub.io
A Curated List of Prometheus Exporters
Stars: ✭ 252 (+833.33%)
Mutual labels:  exporter, prometheus, prometheus-exporter
Github Exporter
Prometheus exporter for github metrics
Stars: ✭ 231 (+755.56%)
Mutual labels:  exporter, prometheus, prometheus-exporter
zfs exporter
Prometheus ZFS exporter
Stars: ✭ 52 (+92.59%)
Mutual labels:  prometheus, prometheus-exporter
github exporter
Prometheus exporter for GitHub
Stars: ✭ 21 (-22.22%)
Mutual labels:  prometheus, prometheus-exporter
loki exporter
Prometheus exporter to collect metrics and run queries against the Grafana Loki API.
Stars: ✭ 28 (+3.7%)
Mutual labels:  prometheus, prometheus-exporter
selectel-exporter
No description or website provided.
Stars: ✭ 25 (-7.41%)
Mutual labels:  exporter, prometheus
opentsdb exporter
Prometheus exporter for OpenTSDB
Stars: ✭ 20 (-25.93%)
Mutual labels:  exporter, prometheus
deluge exporter
Prometheus exporter for the Deluge BitTorrent client
Stars: ✭ 24 (-11.11%)
Mutual labels:  prometheus, prometheus-exporter
resoto
Resoto - Find leaky resources, manage quota limits, detect drift, and clean up!
Stars: ✭ 562 (+1981.48%)
Mutual labels:  prometheus, prometheus-exporter
starboard-exporter
A standalone exporter for vulnerability reports and other CRs created by Starboard.
Stars: ✭ 22 (-18.52%)
Mutual labels:  prometheus, prometheus-exporter
nvidia gpu exporter
Nvidia GPU exporter for prometheus using nvidia-smi binary
Stars: ✭ 85 (+214.81%)
Mutual labels:  prometheus, prometheus-exporter
sentry exporter
Prometheus exporter for Sentry
Stars: ✭ 23 (-14.81%)
Mutual labels:  prometheus, prometheus-exporter
postgres exporter
Postgres exporter
Stars: ✭ 14 (-48.15%)
Mutual labels:  prometheus, prometheus-exporter
jail exporter
A Prometheus exporter for FreeBSD jail metrics
Stars: ✭ 21 (-22.22%)
Mutual labels:  exporter, prometheus
s3 exporter
Exports Prometheus metrics about S3 buckets and objects
Stars: ✭ 65 (+140.74%)
Mutual labels:  prometheus, prometheus-exporter
aws-ec2-sg-exporter
A dockerized Prometheus exporter that compares desired/wanted IPv4/IPv6 CIDR against currently applied inbound CIDR rules in your security group(s).
Stars: ✭ 23 (-14.81%)
Mutual labels:  prometheus, prometheus-exporter
gluster exporter
Gluster Exporter for Prometheus
Stars: ✭ 70 (+159.26%)
Mutual labels:  exporter, prometheus
prometheus-bigquery-exporter
An exporter for converting BigQuery results into Prometheus metrics
Stars: ✭ 27 (+0%)
Mutual labels:  exporter, prometheus

GeoIP Prometheus exporter

Go Report Card

go get github.com/gree-gorey/geoip-exporter

GeoIP exporter collects metrics about TCP-connections, locates remote IP-address and exposes metrics to Prometheus via /metrics endpoint.

Changed https://freegeoip.net/ to https://freegeoip.live/. Please be aware that API has a limit of 10K requests per hour

Example visualization using Grafana:

map

Usage

Available command-line options:

Usage of ./geoip-exporter:
  -blacklist string
    	Addresses blacklist to filter out from results
  -debug
    	Debug log level
  -interval int
    	Interval fo metrics collection in seconds (default 180)
  -web.listen-address string
    	Address on which to expose metrics (default ":9300")

Example

Example usage:

$ ./geoip-exporter --interval=10 --web.listen-address=127.0.0.1:9400 \
    --blacklist="8.8.8.8,4.4.4.4" --debug

Docker quick start

Example usage:

$ docker run -p 9300:9300 greegorey/geoip-exporter:0.2.0

Quick start guide with Grafana

1. Run geoip-exporter

Download latest release:

$ cd /tmp
$ curl -s https://api.github.com/repos/gree-gorey/geoip-exporter/releases/latest \
| grep "browser_download_url" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi - -O geoip-exporter
$ chmod +x geoip-exporter
$ mv geoip-exporter /usr/local/bin

Create service:

# cat << GEO > /etc/systemd/system/geoip-exporter.service
[Unit]
Description=Geo IP exporter for Prometheus
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
Restart=Always
ExecStart=/usr/local/bin/geoip-exporter --interval=300 --web.listen-address=127.0.0.1:9300 --blacklist="104.31.10.172,104.31.11.172"

[Install]
WantedBy=multi-user.target
GEO
# systemctl enable geoip-exporter.service
# systemctl start geoip-exporter.service

Check that the service is running and send the responce:

$ netstat -plnt | grep 9300
tcp        0      0 127.0.0.1:9300        0.0.0.0:*               LISTEN      2156/geoip-exporter
$ curl -s 127.0.0.1:9300/metrics | grep ^job_location
job_location{location="US"} 1

2. Tell Prometheus to collect metrics from geoip-exporter

Change Prometheus configuration file and add the following lines:

  - job_name: 'GeoIPExporter'
    scrape_interval: 10s
    static_configs:
      - targets: ['127.0.0.1:9300']

Then reload Proetheus:

# pgrep "^prometheus$" | xargs -i kill -HUP {}

Go to Prometheus UI and check that it collects metrics:

map

3. Setup Grafana plugin

Then you need to install Worldmap Panel plugin for Grafana:

# grafana-cli plugins install grafana-worldmap-panel

Go to Grafana UI and add new panel (add panel -> Worldmap Panel).
Go to the Metrics tab and add query:

sum(job_location) by (location)

Legend format:

{{location}}

Mark checkpoint Instant.
Your setting should look like this:

map

Then go to the Worldmap tab and set up it as this:

map

From this point on your worldmap panel is ready.

TODO

  • Add command-line flags
  • Add filter for IP addresses (blacklist)
  • Docker image
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].