mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
feat(monitoring): asterisk
This commit is contained in:
parent
340364e5c2
commit
dc9ee1d789
5 changed files with 38 additions and 6 deletions
|
|
@ -24,25 +24,30 @@
|
||||||
port = service.ports.${portName};
|
port = service.ports.${portName};
|
||||||
in "${mkAddress6 (access.getAddressFor system.config.name "lan")}:${toString port.port}";
|
in "${mkAddress6 (access.getAddressFor system.config.name "lan")}:${toString port.port}";
|
||||||
mkServiceConfig = system: serviceName: let
|
mkServiceConfig = system: serviceName: let
|
||||||
|
inherit (service.prometheus) exporter;
|
||||||
service = system.config.exports.services.${serviceName};
|
service = system.config.exports.services.${serviceName};
|
||||||
targets = map (portName:
|
targets = map (portName:
|
||||||
mkPortTarget {
|
mkPortTarget {
|
||||||
inherit system service portName;
|
inherit system service portName;
|
||||||
})
|
})
|
||||||
service.prometheus.exporter.ports;
|
exporter.ports;
|
||||||
in {
|
in {
|
||||||
job_name = "${system.config.name}-${service.id}";
|
job_name = "${system.config.name}-${service.id}";
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{
|
{
|
||||||
inherit targets;
|
inherit targets;
|
||||||
labels = mkMerge [
|
labels = mkMerge [
|
||||||
(mapOptionDefaults service.prometheus.exporter.labels)
|
(mapOptionDefaults exporter.labels)
|
||||||
(mkIf (service.prometheus.exporter.metricsPath != "/metrics") {
|
(mkIf (exporter.metricsPath != "/metrics") {
|
||||||
__metrics_path__ = mkOptionDefault service.prometheus.exporter.metricsPath;
|
__metrics_path__ = mkOptionDefault exporter.metricsPath;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
scheme = mkIf exporter.ssl.enable (mkDefault "https");
|
||||||
|
tls_config = mkIf (exporter.ssl.enable && exporter.ssl.insecure) {
|
||||||
|
insecure_skip_verify = mkDefault true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
mapSystem = system: map (mkServiceConfig system) system.config.exports.prometheus.exporter.services;
|
mapSystem = system: map (mkServiceConfig system) system.config.exports.prometheus.exporter.services;
|
||||||
in {
|
in {
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,19 @@ in {
|
||||||
asterisk = {
|
asterisk = {
|
||||||
port = mkAlmostOptionDefault 8088;
|
port = mkAlmostOptionDefault 8088;
|
||||||
protocol = "http";
|
protocol = "http";
|
||||||
|
prometheus.exporter.enable = let
|
||||||
|
sslPort = config.ports.asterisk-ssl;
|
||||||
|
in mkAlmostOptionDefault (!sslPort.enable || !sslPort.prometheus.exporter.enable);
|
||||||
};
|
};
|
||||||
asterisk-ssl = {
|
asterisk-ssl = {
|
||||||
port = mkAlmostOptionDefault 8089;
|
port = mkAlmostOptionDefault 8089;
|
||||||
protocol = "https";
|
protocol = "https";
|
||||||
|
prometheus.exporter.enable = mkAlmostOptionDefault true;
|
||||||
|
};
|
||||||
|
operator = {
|
||||||
|
enable = mkAlmostOptionDefault false;
|
||||||
|
port = mkAlmostOptionDefault 58080;
|
||||||
|
protocol = "http";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -134,9 +134,10 @@ let
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (gensokyo-zone.lib) mapOptionDefaults;
|
inherit (gensokyo-zone.lib) mapOptionDefaults;
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.modules) mkOptionDefault;
|
inherit (lib.modules) mkOptionDefault;
|
||||||
inherit (lib.attrsets) attrNames filterAttrs;
|
inherit (lib.attrsets) attrNames attrValues filterAttrs;
|
||||||
|
inherit (lib.lists) any;
|
||||||
exporterPorts = filterAttrs (_: port: port.enable && port.prometheus.exporter.enable) config.ports;
|
exporterPorts = filterAttrs (_: port: port.enable && port.prometheus.exporter.enable) config.ports;
|
||||||
statusPorts = filterAttrs (_: port: port.enable && port.status.enable) config.ports;
|
statusPorts = filterAttrs (_: port: port.enable && port.status.enable) config.ports;
|
||||||
in {
|
in {
|
||||||
|
|
@ -153,6 +154,14 @@ let
|
||||||
type = str;
|
type = str;
|
||||||
default = "/metrics";
|
default = "/metrics";
|
||||||
};
|
};
|
||||||
|
ssl = {
|
||||||
|
enable = mkEnableOption "HTTPS" // {
|
||||||
|
default = any (port: port.ssl) (attrValues exporterPorts);
|
||||||
|
};
|
||||||
|
insecure = mkEnableOption "self-signed SSL" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
status = {
|
status = {
|
||||||
|
|
|
||||||
4
systems/freepbx/asterisk-prometheus.conf
Normal file
4
systems/freepbx/asterisk-prometheus.conf
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[general]
|
||||||
|
enabled=yes
|
||||||
|
core_metrics_enabled=yes
|
||||||
|
uri=metrics
|
||||||
|
|
@ -18,6 +18,11 @@ _: {
|
||||||
"/etc/sysconfig/network-scripts/ifcfg-eth0" = {
|
"/etc/sysconfig/network-scripts/ifcfg-eth0" = {
|
||||||
source = ./ifcfg-eth0;
|
source = ./ifcfg-eth0;
|
||||||
};
|
};
|
||||||
|
"/etc/asterisk/prometheus.conf" = {
|
||||||
|
source = ./asterisk-prometheus.conf;
|
||||||
|
owner = "asterisk";
|
||||||
|
group = "asterisk";
|
||||||
|
};
|
||||||
"/root/.ssh/authorized_keys" = {
|
"/root/.ssh/authorized_keys" = {
|
||||||
source = ../reisen/root.authorized_keys;
|
source = ../reisen/root.authorized_keys;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue