Prometheus connection watch exporter

connection watch exporter

Exporter of socket connection status for prometheus.

The exporter generates labeled metrics with the status of the socket connection equivalent to execute:

netstat -nap | grep

Why a connection watch exporter?

Most of the time applications interact each other using sockets. It may not enought to know that the process is running it may be usefull to detect it has connections established on remote machines on specified ports. This exporter reports the status and number of connections according to the configuration.

Getting started

To run it:

./cnxwatch_exporter

by default the exporter will read the configuration file config/config.yml. Another file can be passed as a flag:

./cnxwatch_exporter --config-file=config/user_config.yml

The metrics are available at http://localhost:9293/metrics. Here is an example:

# HELP connection_status_count number of socket with same parameter.
# TYPE connection_status_count gauge
connection_status_count{deshost="*",destport="*",name="hostname-grafana",process="*",protocol="tcp6",srchost="::",srcport="3000",status="listen"} 1
connection_status_count{deshost="127.0.0.1",destport="22",name="ssh-from-localhost",process="*",protocol="tcp",srchost="127.0.0.1",srcport="*",status="established"} 0
# HELP connection_status_up Connection status of the socket (0 down - 1 up).
# TYPE connection_status_up gauge
connection_status_up{deshost="*",destport="*",name="hostname-grafana",process="*",protocol="tcp6",srchost="::",srcport="3000",status="listen"} 1
connection_status_up{deshost="127.0.0.1",destport="22",name="ssh-from-localhost",process="*",protocol="tcp",srchost="127.0.0.1",srcport="*",status="established"} 0

The metrics are:

  • connection_status_up with the labels for each socket iin the config and the following possible values:

    • 1: Connection found
    • 0: Connection not found
  • connection_status_count with the labels for each socket counting the number of connection with the parameters.

Usage

To configure the sockets that te exporter will check, a yaml configuration file is used. This is a configuration example:

sockets:
  - name: hostname-grafana 
    srcHost: "::"
    port: 3000
    status: listen
    protocol: tcp6
  - name: ssh-from-localhost
    srcHost: 127.0.0.1
    destHost: 127.0.0.1
    destPort: 22
    status: established

The fields of the sockets to configure are:

  • name: A name to be able to filter by this in prometheus
  • host or srcHost: source Hostname or IP of the socket
  • port or srcPort: source Port to check. Default empty meaning not checked
  • dstHost: Destination Hostname or IP of the socket. Default empty meaning not checked
  • dstPort: destination Port to check. Default empty meaning not checked
  • protocol: network parameter. Known networks are: "tcp" (IPv4-only), "tcp6" (IPv6-only), "udp" (IPv4-only), "udp6" (IPv6-only. If not defined, it will be set to "tcp" by default.
  • processName: the process owner of the socket; WARNING collected only if root or owner the socket !
  • status: the status of the socket: Should be "listen" or "established".

The following fields will be used as labels in the metric:

  • name
  • srchost
  • srcport
  • dsthost
  • dstport
  • protocol
  • process
  • status

Contributing

Please read the CONTRIBUTING guidelines.

Credits

License

This project is published under Apache 2.0, see LICENSE.

Similar Resources

Prometheus exporter for DeadMansSnitch

DeadMansSnitch Exporter Prometheus exporter for DeadMansSnitch information (snitches) Configuration Usage: deadmanssnitch-exporter [OPTIONS] Applic

Apr 6, 2022

A prometheus exporter for monitoring FIO nodeos nodes.

A prometheus exporter for monitoring FIO nodeos nodes.

fio-prometheus-exporter This is a simple prometheus exporter for FIO nodeos nodes. It can connect to multiple nodes to display a few critical statisti

Aug 19, 2022

A Prometheus exporter, written in Golang, for Magento 2

Magento 2 Prometheus Exporter A Prometheus exporter, written in Golang, for Magento 2. Philosophy It might be abnormal to start with the "philosophy"

May 3, 2022

Prometheus exporter for podman

Prometheus exporter for podman Exports the following metrics for each running container CPU Usage Memory Usage Netowrk Usage Block Usage Output Exampl

Jul 5, 2022

A Prometheus exporter which scrapes metrics from CloudLinux LVE Stats 2

A Prometheus exporter which scrapes metrics from CloudLinux LVE Stats 2

CloudLinux LVE Exporter for Prometheus LVE Exporter - A Prometheus exporter which scrapes metrics from CloudLinux LVE Stats 2 Help on flags: -h, --h

Nov 2, 2021

Prometheus exporter of Hetzner Cloud inventory

Hetzner Cloud inventory exporter Prometheus exporter of Hetzner Cloud inventory Build Using docker Requires docker make build Locally Requires go buil

Dec 14, 2022

A Prometheus metrics exporter for AWS that fills in gaps CloudWatch doesn't cover

YAAE (Yet Another AWS Exporter) A Prometheus metrics exporter for AWS that fills in gaps CloudWatch doesn't cover About This exporter is meant to expo

Dec 10, 2022

Prometheus exporter for IAAS daily billing information

Prometheus exporter for IAAS daily billing information

Multi-iaas-daily-billing-exporter Multi-iaas-daily-billing-exporter enables to collect, unify and expose daily billing from AWS and GCP providers. The

Dec 14, 2021

Prometheus metrics exporter for libvirt.

Libvirt exporter Prometheus exporter for vm metrics written in Go with pluggable metric collectors. Installation and Usage If you are new to Prometheu

Jul 4, 2022
Comments
  • source host

    source host "any" in conjonction with tcp6 protocol ever mismatched

    With configuration

    sockets:
      - name: hostname-grafana 
        srcHost: "*"
        port: '3000'
        status: listen
        protocol: tcp6
    
    

    the results from a scrap are :

    # HELP connection_status_count number of socket with same parameter.
    # TYPE connection_status_count gauge
    connection_status_count{dsthost="*",dstport="*",name="hostname-grafana",process="",protocol="tcp6",srchost="*",srcport="3000",status="listen"} 0
    
    # HELP connection_status_up Connection status of the socket (0 down - 1 up).
    # TYPE connection_status_up gauge
    connection_status_up{dsthost="*",dstport="*",name="hostname-grafana",process="",protocol="tcp6",srchost="*",srcport="3000",status="listen"} 0
    

    in the same time the netstat cmd returns:

    
    # netstat -nap | grep :3000
    tcp6       0      0 :::3000                 :::*                    LISTEN      1401/grafana-server 
    
    
  • value for count and status are inverted

    value for count and status are inverted

    Here an example of the sraped vlaues:

    HELP connection_status_count number of socket with same parameter.

    TYPE connection_status_count gauge

    connection_status_count{dsthost="127.0.0.1",dstport="22",name="ssh-from-localhost",process="",protocol="tcp",srchost="127.0.0.1",srcport="*",status="established"} 1

    HELP connection_status_up Connection status of the socket (0 down - 1 up).

    TYPE connection_status_up gauge

    connection_status_up{dsthost="127.0.0.1",dstport="22",name="ssh-from-localhost",process="",protocol="tcp",srchost="127.0.0.1",srcport="*",status="established"} 5

Json-log-exporter - A Nginx log parser exporter for prometheus metrics

json-log-exporter A Nginx log parser exporter for prometheus metrics. Installati

Jan 5, 2022
Amplitude-exporter - Amplitude charts to prometheus exporter PoC

Amplitude exporter Amplitude charts to prometheus exporter PoC. Work in progress

May 26, 2022
Vulnerability-exporter - A Prometheus Exporter for managing vulnerabilities in kubernetes by using trivy
Vulnerability-exporter - A Prometheus Exporter for managing vulnerabilities in kubernetes by using trivy

Kubernetes Vulnerability Exporter A Prometheus Exporter for managing vulnerabili

Dec 4, 2022
Netstat exporter - Prometheus exporter for exposing reserved ports and it's mapped process

Netstat exporter Prometheus exporter for exposing reserved ports and it's mapped

Feb 3, 2022
Github billing exporter - Billing exporter for GitHub organizations

GitHub billing exporter Forked From: https://github.com/borisputerka/github_bill

Nov 2, 2022
📡 Prometheus exporter that exposes metrics from SpaceX Starlink Dish
📡  Prometheus exporter that exposes metrics from SpaceX Starlink Dish

Starlink Prometheus Exporter A Starlink exporter for Prometheus. Not affiliated with or acting on behalf of Starlink(â„¢) ?? Starlink Monitoring System

Dec 19, 2022
Prometheus exporter for Chia node metrics

chia_exporter Prometheus metric collector for Chia nodes, using the local RPC API Building and Running With the Go compiler tools installed: go build

Sep 19, 2022
Nvidia GPU exporter for prometheus using nvidia-smi binary
Nvidia GPU exporter for prometheus using nvidia-smi binary

nvidia_gpu_exporter Nvidia GPU exporter for prometheus, using nvidia-smi binary to gather metrics. Introduction There are many Nvidia GPU exporters ou

Jan 5, 2023
NVIDIA GPU metrics exporter for Prometheus leveraging DCGM

DCGM-Exporter This repository contains the DCGM-Exporter project. It exposes GPU metrics exporter for Prometheus leveraging NVIDIA DCGM. Documentation

Dec 27, 2022
Prometheus exporter for Amazon Elastic Container Service (ECS)

ecs_exporter ?? ?? ?? This repo is still work in progress and is subject to change. This repo contains a Prometheus exporter for Amazon Elastic Contai

Nov 27, 2022