canonical-ubuntu-qa team mailing list archive
-
canonical-ubuntu-qa team
-
Mailing list archive
-
Message #04067
[Merge] ~andersson123/autopkgtest-cloud:grafana-agent-setup into autopkgtest-cloud:master
Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:grafana-agent-setup into autopkgtest-cloud:master.
Requested reviews:
Canonical's Ubuntu QA (canonical-ubuntu-qa)
For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/466188
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:grafana-agent-setup into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/config.yaml b/charms/focal/autopkgtest-web/config.yaml
index a60637a..4dafb33 100644
--- a/charms/focal/autopkgtest-web/config.yaml
+++ b/charms/focal/autopkgtest-web/config.yaml
@@ -57,3 +57,7 @@ options:
type: string
default: ~
description: "List of teams that are allowed to request autopkgtest tests."
+ grafana-agent-config:
+ type: string
+ default: ~
+ description: "url that the grafana-agent pushes the logtails to."
diff --git a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
index edafb41..1251e05 100644
--- a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
+++ b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
@@ -167,6 +167,54 @@ def initially_configure_website(website):
@when_any(
+ "config.set.grafana-agent-config",
+ "config.changed.grafana-agent-config",
+)
+def write_grafana_agent_config():
+ grafana_agent_autopkgtest_web_config = json.loads(
+ config().get("grafana-agent-config")
+ )
+ grafana_agent_config = f"""
+server: # <- not sure if necessary?
+ log_level: info
+
+logs:
+ configs:
+ - name: autopkgtest-web
+ positions:
+ filename: /tmp/grafana-agent-autopkgtest-web-positions.yaml
+ scrape_configs:
+ - job_name: apache2_access_logs
+ static_configs:
+ - targets: [localhost]
+ labels:
+ job: apache2_access_logs
+ __path__: /var/log/apache2/access.log
+ - job_name: apache2_error_logs
+ static_configs:
+ - targets: [localhost]
+ labels:
+ job: apache2_error_logs
+ __path__: /var/log/apache2/error.log
+ clients:
+ - url: {grafana_agent_autopkgtest_web_config["client-url"]} # <- dummy, change me"""
+ agent_config_file = pathlib.Path("/etc/grafana-agent.yaml")
+ agent_config_file.write_text(grafana_agent_config)
+ # systemctl restart it also
+ # double check this
+ if not subprocess.run(["snap", "info", "grafana-agent"], check=True):
+ subprocess.run(
+ ["snap", "install", "grafana-agent"],
+ check=True,
+ )
+ subprocess.run(
+ ["systemctl", "restart", "snap.grafana-agent.grafana-agent.service"],
+ check=True,
+ )
+ # I think is done, just needs testing!
+
+
+@when_any(
"config.changed.hostname",
"config.changed.https-proxy",
"config.changed.no-proxy",
diff --git a/mojo/service-bundle b/mojo/service-bundle
index 2dfcc49..c794b6c 100644
--- a/mojo/service-bundle
+++ b/mojo/service-bundle
@@ -213,6 +213,7 @@ applications:
{%- if stage_name == "production" or stage_name == "staging" %}
github-secrets: include-file://{{local_dir}}/github-secrets.json
github-status-credentials: include-file://{{local_dir}}/github-status-credentials.txt
+ grafana-agent-config: include-file://{{local_dir}}/grafana-agent-client-url.json
swift-web-credentials: include-file://{{local_dir}}/swift-web-credentials.conf
public-swift-creds: include-file://{{local_dir}}/public-swift-creds
external-web-requests-api-keys: include-file://{{local_dir}}/external-web-requests-api-keys.json
References