Skip to content
Open
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: 9 additions & 2 deletions AzureMonitorAgent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,9 +1671,16 @@ def uninstall_azureotelcollector():
hutil_log_error('Error removing azureotelcollector "{0}"'.format(output))


def is_telegraf_service_installed():
# Whether the telegraf (metrics-sourcer) unit file exists.
try:
return os.path.isfile(telhandler.get_telegraf_service_path(is_lad=False))
except Exception:
return False

def stop_metrics_process():

if telhandler.is_running(is_lad=False):
if telhandler.is_running(is_lad=False) or is_telegraf_service_installed():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe check if its enabled as well right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NarineM Narine Mossikyan (NarineM) Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metrics-sourcer is never [systemctl enabled (only restarted), so an enabled-check wouldn't gate anything — the crash loop comes from the leftover unit file + Restart=on-failure + the health-check restart, independent of enablement.

#Stop the telegraf and ME services
tel_out, tel_msg = telhandler.stop_telegraf_service(is_lad=False)
if tel_out:
Expand Down Expand Up @@ -1976,7 +1983,7 @@ def metrics_watcher(hutil_error, hutil_log):

if len(json_data) == 0:
last_crc = hashlib.sha256(data.encode('utf-8')).hexdigest()
if telhandler.is_running(is_lad=False):
if telhandler.is_running(is_lad=False) or is_telegraf_service_installed():
# Stop the telegraf and ME services
tel_out, tel_msg = telhandler.stop_telegraf_service(is_lad=False)
if tel_out:
Expand Down
Loading