|
27 | 27 | DatabaseRequires,
|
28 | 28 | )
|
29 | 29 | from charms.grafana_k8s.v0.grafana_dashboard import GrafanaDashboardProvider
|
30 |
| -from charms.loki_k8s.v0.loki_push_api import LogProxyConsumer |
| 30 | +from charms.loki_k8s.v0.loki_push_api import LogProxyConsumer, PromtailDigestError |
31 | 31 | from charms.observability_libs.v1.kubernetes_service_patch import KubernetesServicePatch
|
32 | 32 | from charms.openfga_k8s.v1.openfga import OpenFGAProvider, OpenFGAStoreRequestEvent
|
33 | 33 | from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider
|
|
62 | 62 | LOG_FILE,
|
63 | 63 | LOG_PROXY_RELATION_NAME,
|
64 | 64 | METRIC_RELATION_NAME,
|
| 65 | + OPENFGA_METRICS_HTTP_PORT, |
65 | 66 | OPENFGA_RELATION_NAME,
|
66 | 67 | OPENFGA_SERVER_GRPC_PORT,
|
67 | 68 | OPENFGA_SERVER_HTTP_PORT,
|
@@ -111,14 +112,18 @@ def __init__(self, *args: Any) -> None:
|
111 | 112 | self,
|
112 | 113 | log_files=[LOG_FILE],
|
113 | 114 | relation_name=LOG_PROXY_RELATION_NAME,
|
114 |
| - promtail_resource_name="promtail-bin", |
115 | 115 | container_name=WORKLOAD_CONTAINER,
|
116 | 116 | )
|
117 | 117 |
|
118 | 118 | # Prometheus metrics endpoint relation
|
119 | 119 | self.metrics_endpoint = MetricsEndpointProvider(
|
120 | 120 | self,
|
121 |
| - jobs=[{"static_configs": [{"targets": [f"*:{OPENFGA_SERVER_HTTP_PORT}"]}]}], |
| 121 | + jobs=[ |
| 122 | + { |
| 123 | + "metrics_path": "/metrics", |
| 124 | + "static_configs": [{"targets": [f"*:{OPENFGA_METRICS_HTTP_PORT}"]}], |
| 125 | + } |
| 126 | + ], |
122 | 127 | refresh_event=self.on.config_changed,
|
123 | 128 | relation_name=METRIC_RELATION_NAME,
|
124 | 129 | )
|
@@ -161,14 +166,20 @@ def __init__(self, *args: Any) -> None:
|
161 | 166 | self._on_database_changed,
|
162 | 167 | )
|
163 | 168 | self.framework.observe(self.on.database_relation_broken, self._on_database_relation_broken)
|
| 169 | + self.framework.observe( |
| 170 | + self.log_proxy.on.promtail_digest_error, self._on_promtail_digest_error |
| 171 | + ) |
164 | 172 |
|
165 | 173 | port_http = ServicePort(
|
166 | 174 | OPENFGA_SERVER_HTTP_PORT, name=f"{self.app.name}-http", protocol="TCP"
|
167 | 175 | )
|
168 | 176 | port_grpc = ServicePort(
|
169 | 177 | OPENFGA_SERVER_GRPC_PORT, name=f"{self.app.name}-grpc", protocol="TCP"
|
170 | 178 | )
|
171 |
| - self.service_patcher = KubernetesServicePatch(self, [port_http, port_grpc]) |
| 179 | + port_metrics = ServicePort( |
| 180 | + OPENFGA_METRICS_HTTP_PORT, name=f"{self.app.name}-metrics", protocol="TCP" |
| 181 | + ) |
| 182 | + self.service_patcher = KubernetesServicePatch(self, [port_http, port_grpc, port_metrics]) |
172 | 183 |
|
173 | 184 | def _on_openfga_pebble_ready(self, event: PebbleReadyEvent) -> None:
|
174 | 185 | """Workload pebble ready."""
|
@@ -212,6 +223,10 @@ def _get_database_relation_info(self) -> Optional[Dict]:
|
212 | 223 | "database_name": DATABASE_NAME,
|
213 | 224 | }
|
214 | 225 |
|
| 226 | + def _on_promtail_digest_error(self, event: PromtailDigestError) -> None: |
| 227 | + """Log PromtailDigestError error.""" |
| 228 | + logger.error(f'got PromtailDigestError with message: "{event.message}"') |
| 229 | + |
215 | 230 | @property
|
216 | 231 | def _log_level(self) -> str:
|
217 | 232 | return self.config["log-level"]
|
|
0 commit comments