diff --git a/README.md b/README.md index 4cb5092..c173d73 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,13 @@ juju deploy ubuntu juju deploy prometheus-node-exporter -juju add-relation prometheus-node-exporter ubuntu +juju integrate prometheus-node-exporter ubuntu -juju add-relation prometheus-node-exporter:scrape prometheus:scrape +juju integrate prometheus-node-exporter:prometheus-target prometheus:target + +# juju integrate prometheus-node-exporter:prometheus-manual-job prometheus:manual-jobs + +# juju integrate prometheus-node-exporter:scrape prometheus:scrape ``` ## Custom node_exporter diff --git a/layer.yaml b/layer.yaml index bd3c7af..0e75628 100644 --- a/layer.yaml +++ b/layer.yaml @@ -7,6 +7,7 @@ "python_packages": [] "includes": - "layer:basic" +- "interface:http" - "interface:prometheus" - "interface:prometheus-manual" "repo": "https://github.com/CanonicalLtd/prometheus-node-exporter-charm" diff --git a/reactive/prometheus_node_exporter.py b/reactive/prometheus_node_exporter.py index 292ce7f..afecba4 100644 --- a/reactive/prometheus_node_exporter.py +++ b/reactive/prometheus_node_exporter.py @@ -10,7 +10,8 @@ resource_get, status_set, unit_private_ip, - unit_public_ip + unit_public_ip, + application_name, ) from charmhelpers.core.host import ( add_group, @@ -165,13 +166,13 @@ def prometheus_left(): @when('prometheus-target.available') def configure_http(prometheus_target): - job_name = 'node-exporter' + job_name = application_name() log('Register target {}: {}:{}'.format( job_name, get_ip()[1], - config.get('port') + config('port') )) - open_port(config.get('port')) + open_port(config('port')) prometheus_target.configure( private_address=get_ip()[1], port=config('port') diff --git a/tests/bundles/jammy.yaml b/tests/bundles/jammy.yaml index 7bf41e7..fe863ca 100644 --- a/tests/bundles/jammy.yaml +++ b/tests/bundles/jammy.yaml @@ -1,9 +1,11 @@ series: jammy relations: +- - prometheus-node-exporter:prometheus-target + - prometheus:target - - prometheus-node-exporter:juju-info - ubuntu:juju-info -- - prometheus-node-exporter:prometheus-manual-job - - prometheus:manual-jobs +- - prometheus-node-exporter:juju-info + - app:juju-info applications: prometheus: charm: prometheus2 @@ -17,3 +19,6 @@ applications: ubuntu: charm: huntdatacenter-ubuntu-lite num_units: 1 + app: + charm: huntdatacenter-ubuntu-lite + num_units: 1