-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Machine charm lib #95
Conversation
At this point we have the first and dirty "working" version. With the following two controllers/models running microk8s running loki, prometheus and grafana$ juju status --color --relations -m charm-dev-batteries:cos
Model Controller Cloud/Region Version SLA Timestamp
cos charm-dev-batteries microk8s/localhost 2.9.37 unsupported 18:08:02-03:00
SAAS Status Store URL
grafana-agent unknown lxd admin/cos.grafana-agent
App Version Status Scale Charm Channel Rev Address Exposed Message
grafana 9.2.1 active 1 grafana-k8s edge 70 10.152.183.167 no
loki 2.4.1 active 1 loki-k8s edge 65 10.152.183.70 no
prometheus 2.33.5 active 1 prometheus-k8s stable 103 10.152.183.216 no
Unit Workload Agent Address Ports Message
grafana/0* active idle 10.1.82.238
loki/0* active idle 10.1.82.242
prometheus/0* active idle 10.1.82.235
Offer Application Charm Rev Connected Endpoint Interface Role
grafana grafana grafana-k8s 70 0/0 grafana-dashboard grafana_dashboard requirer
loki loki loki-k8s 65 1/1 logging loki_push_api provider
prometheus prometheus prometheus-k8s 103 1/1 receive-remote-write prometheus_remote_write provider
Relation provider Requirer Interface Type Message
grafana-agent:grafana-dashboards-provider grafana:grafana-dashboard grafana_dashboard regular
grafana:grafana grafana:grafana grafana_peers peer
prometheus:grafana-source grafana:grafana-source grafana_datasource regular
prometheus:prometheus-peers prometheus:prometheus-peers prometheus_peers peer lxd running zookeeper and grafana-agent:$ juju status --color --relations -m lxd:cos
Model Controller Cloud/Region Version SLA Timestamp
cos lxd localhost/localhost 2.9.38 unsupported 18:09:52-03:00
SAAS Status Store URL
grafana active charm-dev-batteries admin/cos.grafana
loki active charm-dev-batteries admin/cos.loki
prometheus active charm-dev-batteries admin/cos.prometheus
App Version Status Scale Charm Channel Rev Exposed Message
grafana-agent active 1 grafana-agent 29 no
zookeeper active 1 zookeeper 4 no
Unit Workload Agent Machine Public address Ports Message
zookeeper/10* active idle 25 10.77.61.135
grafana-agent/29* active idle 10.77.61.135
Machine State Address Inst id Series AZ Message
25 started 10.77.61.135 juju-5599db-25 jammy Running
Offer Application Charm Rev Connected Endpoint Interface Role
grafana-agent grafana-agent grafana-agent 29 0/0 grafana-dashboards-provider grafana_dashboard provider
Relation provider Requirer Interface Type Message
loki:logging grafana-agent:logging-consumer loki_push_api regular
prometheus:receive-remote-write grafana-agent:send-remote-write prometheus_remote_write regular
zookeeper:cluster zookeeper:cluster cluster peer
zookeeper:cos-machine grafana-agent:cos-machine cos_machine subordinate
zookeeper:restart zookeeper:restart rolling_op peer Grafana agent config file is: ubuntu@juju-5599db-25:~$ cat /etc/grafana-agent.yaml
integrations:
agent:
enabled: true
relabel_configs:
- regex: (.*)
replacement: juju_cos_78c35b57-e906-4f31-860a-71165d5599db_grafana-agent_self-monitoring
target_label: job
- regex: (.*)
replacement: ''
target_label: instance
- replacement: grafana-agent
source_labels:
- __address__
target_label: juju_charm
- replacement: cos
source_labels:
- __address__
target_label: juju_model
- replacement: 78c35b57-e906-4f31-860a-71165d5599db
source_labels:
- __address__
target_label: juju_model_uuid
- replacement: grafana-agent
source_labels:
- __address__
target_label: juju_application
- replacement: grafana-agent/29
source_labels:
- __address__
target_label: juju_unit
node_exporter:
enabled: true
relabel_configs:
- regex: (.*)
replacement: juju_cos_78c35b57-e906-4f31-860a-71165d5599db_grafana-agent_node-exporter
target_label: job
- regex: (.*)
replacement: ''
target_label: instance
prometheus_remote_write:
- tls_config:
insecure_skip_verify: false
url: http://prometheus-0.prometheus-endpoints.cos.svc.cluster.local:9090/api/v1/write
logs:
configs:
- clients:
- tls_config:
insecure_skip_verify: false
url: http://loki-0.loki-endpoints.cos.svc.cluster.local:3100/loki/api/v1/push
name: push_api_server
positions:
filename: /run/promtail-positions.yaml
scrape_configs:
- job_name: loki
loki_push_api:
server:
grpc_listen_port: 3600
http_listen_port: 3500
- clients:
- tls_config:
insecure_skip_verify: false
url: http://loki-0.loki-endpoints.cos.svc.cluster.local:3100/loki/api/v1/push
name: log_file_scraper
positions:
filename: /run/promtail-positions.yaml
scrape_configs:
- job_name: varlog
static_configs:
- labels:
__path__: /var/log/*log
instance: ''
targets:
- localhost
- job_name: syslog
journal:
labels:
instance: ''
metrics:
configs:
- name: agent_scraper
remote_write:
- url: http://prometheus-0.prometheus-endpoints.cos.svc.cluster.local:9090/api/v1/write
scrape_configs:
- job_name: zookeeper_0
path: /metrics
port: 9100
- job_name: zookeeper_1
path: /metrics
port: 9998
- job_name: zookeeper_2
path: /metrics
port: 7000
- job_name: zookeeper_2
metrics_path: /metrics
static_configs:
- targets:
- localhost:7000
wal_directory: /tmp/agent/data
server:
log_level: info In order to integrate zookeeper with grafana agent: 2023-03-06 16:41:51.961 :: 2023-03-06 19:41:43.897 :: Translated .jujuignore 1 '/staging-venv' => '/staging\\-venv\\Z'
2023-03-06 16:41:51.961 :: 2023-03-06 19:41:43.897 :: Building charm in '/root/parts/charm/install'
2023-03-06 16:41:51.962 :: 2023-03-06 19:41:43.897 :: Linking in generic paths
2023-03-06 16:41:51.962 :: 2023-03-06 19:41:43.897 :: Ignoring directory because of rules: 'staging-venv'
@@ -25,6 +25,8 @@ provides:
interface: prometheus_scrape
grafana-dashboard:
interface: grafana_dashboard
+ cos-machine:
+ interface: cos_machine
requires:
certificates:
diff --git a/src/charm.py b/src/charm.py
index 1972f12..cc66d0b 100755
--- a/src/charm.py
+++ b/src/charm.py
@@ -10,6 +10,7 @@ import time
from charms.grafana_k8s.v0.grafana_dashboard import GrafanaDashboardProvider
from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider
from charms.rolling_ops.v0.rollingops import RollingOpsManager
+from charms.grafana_agent.v0.cos_machine import COSMachineProvider
from cluster import ZooKeeperCluster
from config import ZooKeeperConfig
from literals import CHARM_KEY, CHARM_USERS, JMX_PORT, METRICS_PROVIDER_PORT, NODE_EXPORTER_PORT
@@ -62,6 +63,14 @@ class ZooKeeperCharm(CharmBase):
],
)
+ self._grafana_agent = COSMachineProvider(
+ self, metrics_endpoints=[
+ {"path": "/metrics", "port": NODE_EXPORTER_PORT},
+ {"path": "/metrics", "port": JMX_PORT},
+ {"path": "/metrics", "port": METRICS_PROVIDER_PORT},
+ ]
+ )
+
self.framework.observe(getattr(self.on, "install"), self._on_install)
self.framework.observe(getattr(self.on, "update_status"), self.update_quorum)
self.framework.observe( |
…ntil we hit the bottom
…t-k8s-operator into machine_charm_lib
When I relate to loki, grafana-agent fails to start
|
@dstathis Please, may you paste the content of the /etc/grafana-agent.yaml file? |
For which issue? |
This one: ubuntu@juju-488a58-4:~$ /usr/bin/snap run grafana-agent
2023/03/07 15:09:25 error loading config file /etc/grafana-agent.yaml: Loki configs push_api_server and log_file_scraper must have different positions file paths |
|
…t-k8s-operator into machine_charm_lib
* Cleanup etc. (#90) * Fix metadata and snap usage (#91) * Class split (#92) * Make static_configs into a list (#96) * add option for tls insecure skip verify (#93) * Add dashboards handler (#97) * Scenario tests and machine charm rename (#99) * spelling errors (#100) * Clear machine metadata relations (#98) * Add tests for update-status (#101) * Type fixes (#102) * small fixes and scenarios (#103) * Machine charm lib (#95) * Feature/fix prop (#111) * LINT. Fix the grafana data iteration (#112) * plug extraction (#105) * Sub relation priority (#114) * Fix a possible JSON loading exception (#119) * purged grafana dashboard requirer (#117) * Fix labels (#120) * Use cosl for Rules and JujuTopology (#121) * Fix position files (#116) * top level documentation for cos_machine lib (#122) * Add juju-info itest (#123) * Snap plug logs (#124) * Loki shared logs monitoring (#125) * Rename cos-machine to cos-agent (#129) * wrong scope for grafana-dashboards-provider relation (#134) * FIX Grafana dashboards files are stored in a bad format (#139) * move on-refresh config to unit databag (#142) * Set BlockedStatus per relation (#141) * Be looser with finding snap plug mounts (#145) * Use an actual uuid4, alerts() is now a property everywhere (#151) * Replace DS_PROMETHEUS with prometheusds (#148) * Cleanup (#152) * use better locations for the positions files (#155) * added typing for metrics endpoint dict (#149) * Fix fstab parser (#159) * (cos-agent) Use peer relation data for communicating all principals' data (#160) * add support for the grafana cloud integrator charm (#150) Co-authored-by: Dylan Stephano-Shachter <dylan.stephano-shachter@canonical.com> Co-authored-by: awnn <adrian@webyda.se> Co-authored-by: Ryan Barry <ryan.barry@canonical.com> Co-authored-by: PietroPasotti <pietro.pasotti@canonical.com> Co-authored-by: Jose C. Massón <939888+Abuelodelanada@users.noreply.github.com> Co-authored-by: sed-i <82407168+sed-i@users.noreply.github.com> Co-authored-by: Simon Aronsson <simme@arcticbit.se> Co-authored-by: Luca Bello <36242061+lucabello@users.noreply.github.com>
Grafana Agent machine charm lib.