From 98a0472352742242721023e11b5b58a97fd0d3ff Mon Sep 17 00:00:00 2001 From: Evelyn Alicke Date: Tue, 13 Feb 2024 12:44:35 +0100 Subject: [PATCH] chore: cleanup dev env closes: https://github.com/famedly/openmetrics-vici-exporter/issues/6 --- README.md | 28 ++++++---- docker-compose.yml | 7 +-- flake.lock | 130 +++++++++++++++++++++++++++++++++++++++++++++ rustfmt.toml | 1 - shell.nix | 5 -- 5 files changed, 153 insertions(+), 18 deletions(-) create mode 100644 flake.lock delete mode 100644 rustfmt.toml delete mode 100644 shell.nix diff --git a/README.md b/README.md index 2af895b..16c50dc 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,38 @@ -[![CI](https://github.com/famedly/openmetrics-vici-expoter/actions/workflows/build.yml/badge.svg?event=release)](https://github.com/famedly/openmetrics-vici-expoter/actions/workflows/build.yml) - # openmetrics-vici-exporter provides an openmetrics compatible endpoint for strongSwan charon's VICI. initally tested against strongSwan 5.9 and strongSwan 6.0. -## deployment -pull container image from `ghcr.io`, see `docker-compose.yml` in this repo +## Usage +### Deployment +for pre-build binaries see [Releases](/releases) +we also provide a docker container. +`docker pull docker-oss.nexus.famedly.de/openmetrics-vici-exporter` + +## Configuration +an exhaustive default configuration is provided as [`config.yml`](/blob/main/config.yml) +
+all the keys can also be set as environment variables if you prefer this. +they will be prefixed with `VICI_EXPORTER` +for example, you would configure the vici polling interval by setting `VICI_EXPORTER_VICI_INTERVAL=10` -## development +## Development +you need to make sure to have strongswan running and some connections configured and running, aswell as your user to haev the necessary permissions to access the socket. + +1. `nix develop` 1. `sudo groupadd vici` 2. `sudo chown root:vici /var/run/charon.vici` 3. `sudo chmod 0770 /var/run/charon.vici` -4. `sudo usermod -aG vici $user` +4. `sudo usermod -aG vici $(whoami)` 5. `cargo run` 6. `curl http://localhost:8001/metrics` - -## license +## License [AGPL-3.0-only](LICENSE.md) -## authors +## Authors - Evelyn Alicke diff --git a/docker-compose.yml b/docker-compose.yml index 4da34ef..95af8ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,8 @@ version: '3' services: - ove: + openmetrics-vici-exporter: + image: docker-oss.famedly.de/openmetrics-vici-exporter restart: "unless-stopped" environment: - VICI_EXPORTER_VICI_SOCKET="/var/run/charon.vici" @@ -9,7 +10,7 @@ services: - VICI_EXPORTER_SERVER_ADDRESS=0.0.0.0 - VICI_EXPORTER_SERVER_PORT=8001 volumes: - #- ./config.yml:/opt/openmetrics-vici-exporter/config.yml + # - ./config.yml:/opt/openmetrics-vici-exporter/config.yml - /var/run/charon.vici:/var/run/charon.vici ports: - - 8111:80/tcp + - 8001:8001/tcp diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..393be08 --- /dev/null +++ b/flake.lock @@ -0,0 +1,130 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1698611440, + "narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1698726852, + "narHash": "sha256-V1S4TTzg++GzPc96i/yy4jib+7/xU0LXHcggm9MllMM=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "ec19bd20af08f3b004089cc12ab54c823ed899b7", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index 7530651..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -max_width = 120 diff --git a/shell.nix b/shell.nix deleted file mode 100644 index cb1f424..0000000 --- a/shell.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ pkgs ? import {} }: - pkgs.mkShell { - packages = with pkgs; [ rustc cargo gcc rustfmt clippy ]; - name = "rust-env"; -}