-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport post-setup healthcheck from agent to alloy (#213)
Co-authored-by: Ishan Jain <[email protected]>
- Loading branch information
1 parent
8dbd124
commit 8cf67f0
Showing
4 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Health check Grafana Alloy | ||
ansible.builtin.uri: | ||
url: "{{ _alloy_healthcheck_endpoint }}" | ||
follow_redirects: none | ||
method: GET | ||
register: _result | ||
failed_when: false | ||
until: _result.status == 200 | ||
retries: 3 | ||
delay: 5 | ||
changed_when: false | ||
when: not ansible_check_mode | ||
|
||
- name: Check system logs if Grafana Alloy is not started | ||
when: not ansible_check_mode and _result.status != 200 | ||
block: | ||
- name: Run journalctl | ||
ansible.builtin.shell: | ||
cmd: "journalctl -u {{ service_name }} -b -n20 --no-pager" | ||
register: journal_ret | ||
changed_when: false | ||
- name: Output Grafana Alloy logs | ||
ansible.builtin.debug: | ||
var: journal_ret.stdout_lines | ||
- name: Raise alerts | ||
ansible.builtin.assert: | ||
that: false | ||
fail_msg: "Service {{ service_name }} hasn't started." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Server http address, used in self health check after start | ||
_alloy_healthcheck_endpoint: "http://{{ alloy_flags_extra['server.http.listen-addr'] if alloy_flags_extra['server.http.listen-addr'] is defined else '127.0.0.1:12345' }}/-/ready" |