Skip to content
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

metrics endpoint generated using fqdn #222

Merged
merged 4 commits into from Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/charm.py
Expand Up @@ -123,8 +123,11 @@ def __init__(self, *args):

self.metrics_endpoint = MetricsEndpointProvider(
charm=self,
jobs=[{"static_configs": [{"targets": ["*:3000"]}]}],
refresh_event=self.on.grafana_pebble_ready, # pyright: ignore
jobs=self._scrape_jobs,
refresh_event=[
self.on.grafana_pebble_ready, # pyright: ignore
self.on.update_status,
],
)

# -- standard events
Expand Down Expand Up @@ -1175,6 +1178,18 @@ def generate_auth_env_vars(self, conf: Dict[str, Dict[str, Any]]) -> Dict[str, s
env_vars[auth_var_prefix + str(var).upper()] = str(conf[auth_mode][var])
return env_vars

@property
def _hostname(self) -> str:
return socket.getfqdn()

@property
def _scrape_jobs(self) -> list:
return [
{
"static_configs": [{"targets": [f"{self._hostname}:{PORT}"]}],
}
]


if __name__ == "__main__":
main(GrafanaCharm, use_juju_for_storage=True)
3 changes: 2 additions & 1 deletion tox.ini
Expand Up @@ -86,7 +86,8 @@ description = Run integration tests
deps =
aiohttp
asyncstdlib
juju
# Libjuju needs to track the juju version
juju ~= 3.1.0
pytest
pytest-operator
commands =
Expand Down