This commit is contained in:
parent
b108d02f59
commit
bf21b3b7c8
6 changed files with 95 additions and 32 deletions
|
@ -1,7 +1,10 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let cfg = config.services.vmagent;
|
let
|
||||||
in {
|
cfg = config.services.vmagent;
|
||||||
|
settingsFormat = pkgs.formats.json { };
|
||||||
|
in
|
||||||
|
{
|
||||||
options.services.vmagent = {
|
options.services.vmagent = {
|
||||||
enable = mkEnableOption "vmagent";
|
enable = mkEnableOption "vmagent";
|
||||||
|
|
||||||
|
@ -22,8 +25,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
default = pkgs.v.vmagent;
|
default = pkgs.vmagent;
|
||||||
defaultText = "pkgs.v.vmagent";
|
defaultText = "pkgs.vmagent";
|
||||||
type = types.package;
|
type = types.package;
|
||||||
description = ''
|
description = ''
|
||||||
vmagent package to use.
|
vmagent package to use.
|
||||||
|
@ -47,16 +50,17 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
prometheusConfig = mkOption {
|
prometheusConfig = mkOption {
|
||||||
default = "";
|
type = lib.types.submodule {
|
||||||
type = types.str;
|
freeformType = settingsFormat.type;
|
||||||
example = ''
|
};
|
||||||
global:
|
# example = ''
|
||||||
scrape_interval: 5s
|
# global:
|
||||||
scrape_configs:
|
# scrape_interval: 5s
|
||||||
- job_name: 'apache'
|
# scrape_configs:
|
||||||
static_configs:
|
# - job_name: 'apache'
|
||||||
- targets: ['apache-exporter:9117']
|
# static_configs:
|
||||||
'';
|
# - targets: ['apache-exporter:9117']
|
||||||
|
# '';
|
||||||
description = ''
|
description = ''
|
||||||
Config for prometheus style metrics
|
Config for prometheus style metrics
|
||||||
'';
|
'';
|
||||||
|
@ -90,7 +94,8 @@ in {
|
||||||
networking.firewall.allowedTCPPorts = mkIf (cfg.openFirewall) [ 8429 ];
|
networking.firewall.allowedTCPPorts = mkIf (cfg.openFirewall) [ 8429 ];
|
||||||
|
|
||||||
# The actual service
|
# The actual service
|
||||||
systemd.services.vmagent = let prometheusConfig = pkgs.writeText "prometheus.yml" cfg.prometheusConfig;
|
systemd.services.vmagent =
|
||||||
|
let prometheusConfig = settingsFormat.generate "prometheusConfig.yaml" cfg.prometheusConfig;
|
||||||
in {
|
in {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
|
|
|
@ -62,7 +62,7 @@ in
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
locations."/".extraConfig = ''
|
locations."/".extraConfig = ''
|
||||||
add_header Content-Type 'text/html; charset=UTF-8';
|
add_header Content-Type 'text/html; charset=UTF-8';
|
||||||
return 200 meow;
|
return 200 '<h1>meow</h1>';
|
||||||
'';
|
'';
|
||||||
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
|
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
|
||||||
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
|
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
let
|
let
|
||||||
vs = config.vault-secrets.secrets;
|
vs = config.vault-secrets.secrets;
|
||||||
port = 8008;
|
port = 8008;
|
||||||
|
metricsPort = 9000;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ];
|
imports = [ ];
|
||||||
|
@ -23,7 +24,7 @@ in
|
||||||
# Additional packages
|
# Additional packages
|
||||||
environment.systemPackages = with pkgs; [ ];
|
environment.systemPackages = with pkgs; [ ];
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ port ];
|
networking.firewall.allowedTCPPorts = [ port metricsPort ];
|
||||||
|
|
||||||
vault-secrets.secrets.synapse = {
|
vault-secrets.secrets.synapse = {
|
||||||
user = "matrix-synapse";
|
user = "matrix-synapse";
|
||||||
|
@ -65,6 +66,7 @@ in
|
||||||
server_name = "meowy.tech";
|
server_name = "meowy.tech";
|
||||||
enable_registration = true;
|
enable_registration = true;
|
||||||
public_baseurl = "https://chat.meowy.tech";
|
public_baseurl = "https://chat.meowy.tech";
|
||||||
|
enable_metrics = true;
|
||||||
listeners = [
|
listeners = [
|
||||||
{
|
{
|
||||||
inherit port;
|
inherit port;
|
||||||
|
@ -79,6 +81,18 @@ in
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
port = metricsPort;
|
||||||
|
bind_addresses = [ "0.0.0.0" ];
|
||||||
|
type = "metrics";
|
||||||
|
tls = false;
|
||||||
|
resources = [
|
||||||
|
{
|
||||||
|
names = [ "metrics" ];
|
||||||
|
compress = false;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
let
|
let
|
||||||
vmPort = 8428;
|
vmPort = 8428;
|
||||||
vs = config.vault-secrets.secrets;
|
vs = config.vault-secrets.secrets;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
imports = [ ];
|
imports = [ ];
|
||||||
|
|
||||||
networking.hostName = "victoriametrics";
|
networking.hostName = "victoriametrics";
|
||||||
|
@ -32,6 +33,24 @@ in {
|
||||||
retentionPeriod = 12;
|
retentionPeriod = 12;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.vmagent = {
|
||||||
|
enable = true;
|
||||||
|
openFirewall = true;
|
||||||
|
prometheusConfig = {
|
||||||
|
global.scrape_interval = "5s";
|
||||||
|
scrape_configs = [
|
||||||
|
{
|
||||||
|
job_name = "synapse";
|
||||||
|
metrics_path = "/_synapse/metrics";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "synapse.olympus:9000" ];
|
||||||
|
labels.app = "synapse";
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
vault-secrets.secrets.grafana = {
|
vault-secrets.secrets.grafana = {
|
||||||
user = "grafana";
|
user = "grafana";
|
||||||
group = "grafana";
|
group = "grafana";
|
||||||
|
|
|
@ -6,6 +6,8 @@ final: prev: {
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vmagent = prev.callPackage ./vmagent { };
|
||||||
|
|
||||||
v = {
|
v = {
|
||||||
unbound = prev.unbound.override {
|
unbound = prev.unbound.override {
|
||||||
withSystemd = true;
|
withSystemd = true;
|
||||||
|
|
23
nixos/pkgs/vmagent/default.nix
Normal file
23
nixos/pkgs/vmagent/default.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ lib, fetchFromGitHub, buildGoModule }:
|
||||||
|
buildGoModule rec {
|
||||||
|
pname = "vmagent";
|
||||||
|
version = "1.79.0";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "VictoriaMetrics";
|
||||||
|
repo = "VictoriaMetrics";
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "sha256-+LirbGbKeazXMtgVh5kZP+KEk/fDbSxceZ26OlE0hbY=";
|
||||||
|
};
|
||||||
|
|
||||||
|
vendorSha256 = null;
|
||||||
|
|
||||||
|
subPackages = [ "app/vmagent" ];
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "VictoriaMetrics metrics scraper";
|
||||||
|
homepage = "https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master/app/vmagent";
|
||||||
|
license = licenses.asl20;
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue