Skip to content

Commit

Permalink
fix target relation
Browse files Browse the repository at this point in the history
  • Loading branch information
matuskosut committed Jun 16, 2023
1 parent cc3127d commit f1f5b57
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions layer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 5 additions & 4 deletions reactive/prometheus_node_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Expand Down
9 changes: 7 additions & 2 deletions tests/bundles/jammy.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,3 +19,6 @@ applications:
ubuntu:
charm: huntdatacenter-ubuntu-lite
num_units: 1
app:
charm: huntdatacenter-ubuntu-lite
num_units: 1

0 comments on commit f1f5b57

Please sign in to comment.