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

Fix position files #116

Merged
merged 3 commits into from
Mar 9, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/grafana_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class GrafanaAgentCharm(CharmBase):
"""Grafana Agent Charm."""

_name = "agent"
_promtail_positions = "/run/promtail-positions.yaml"
_http_listen_port = 3500
_grpc_listen_port = 3600

Expand Down Expand Up @@ -446,7 +445,6 @@ def _loki_config(self) -> Dict[str, List[Any]]:
{
"name": "push_api_server",
"clients": loki_endpoints,
"positions": {"filename": self._promtail_positions},
"scrape_configs": [
{
"job_name": "loki",
Expand All @@ -462,7 +460,14 @@ def _loki_config(self) -> Dict[str, List[Any]]:
)

configs.extend(self._additional_log_configs) # type: ignore
return {"configs": configs} if configs else {}
return (
{
"positions_directory": "/tmp/grafana-agent-positions",
"configs": configs,
}
if configs
else {}
)

@property
def _instance_topology(self) -> Dict[str, str]:
Expand Down
4 changes: 1 addition & 3 deletions src/machine_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def _additional_log_configs(self) -> List[Dict[str, Any]]:
{
"name": "log_file_scraper",
"clients": loki_endpoints,
"positions": {"filename": self._promtail_positions},
"scrape_configs": [
{
"job_name": "varlog",
Expand Down Expand Up @@ -288,8 +287,7 @@ def _update_snap_logs(self):
try:
subprocess.check_output(shlex.split(cmd))
except subprocess.CalledProcessError:
logger.error(f"error connecting plug {plug} to grafana-agent:logs",
exc_info=True)
logger.error(f"error connecting plug {plug} to grafana-agent:logs", exc_info=True)
# TODO: figure out if we need to do anything to add the new log dirs/files to the tail


Expand Down