-
Notifications
You must be signed in to change notification settings - Fork 20
feat: Replace prometheus with metricbeat by extending the elastic_stack role #628
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
Draft
vivekgsharma
wants to merge
9
commits into
v1.0-dev
Choose a base branch
from
Prometheus_metricbeats
base: v1.0-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3574d36
configured elastic_beat role to collect logs using metricbeat
vivekgsharma b189170
small fix
vivekgsharma 6c0d6a6
added logs parser and alerts
vivekgsharma 7a2a823
small fix
vivekgsharma e7f157b
smaall fix2
vivekgsharma 6a07011
fixed main.yml in elastic_beats
vivekgsharma df00232
small fix
vivekgsharma 25f7d21
fix5
vivekgsharma 6608e07
defined elasticsearch_uri
vivekgsharma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
11 changes: 11 additions & 0 deletions
11
ansible/roles/elastic_stack/files/pipelines/process_proposal_pipeline.json
This file contains hidden or 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,11 @@ | ||
{ | ||
"description": "Parse round number from Tenderdash logs", | ||
"processors": [ | ||
{ | ||
"grok": { | ||
"field": "message", | ||
"patterns": ["Processed proposal with .* for height: %{NUMBER:height}, round: %{NUMBER:round}"] | ||
} | ||
} | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
ansible/roles/elastic_stack/files/watches/error_logs_watch.json
This file contains hidden or 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,33 @@ | ||
{ | ||
"trigger": { | ||
"schedule": { | ||
"interval": "10s" | ||
} | ||
}, | ||
"input": { | ||
"search": { | ||
"request": { | ||
"indices": ["logs-*"], | ||
"body": { | ||
"query": { | ||
"bool": { | ||
"should": [ | ||
{ "match": { "log.level": "ERROR" }}, | ||
{ "match": { "log.level": "FATAL" }} | ||
], | ||
"minimum_should_match": 1 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"actions": { | ||
"log_alert": { | ||
"logging": { | ||
"text": "Alert triggered: {{ctx.payload}}" | ||
} | ||
} | ||
} | ||
} | ||
|
41 changes: 41 additions & 0 deletions
41
ansible/roles/elastic_stack/files/watches/high_round_watch.json
This file contains hidden or 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,41 @@ | ||
{ | ||
"trigger": { | ||
"schedule": { | ||
"interval": "10s" | ||
} | ||
}, | ||
"input": { | ||
"search": { | ||
"request": { | ||
"indices": ["logs-*"], | ||
"body": { | ||
"query": { | ||
"bool": { | ||
"must": [ | ||
{ | ||
"match": { | ||
"message": "Processed proposal" | ||
} | ||
}, | ||
{ | ||
"range": { | ||
"round": { | ||
"gt": 5 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"actions": { | ||
"log_alert": { | ||
"logging": { | ||
"text": "Alert triggered: {{ctx.payload}}" | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
ansible/roles/elastic_stack/files/watches/no_logs_watch.json
This file contains hidden or 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,46 @@ | ||
{ | ||
"trigger": { | ||
"schedule": { | ||
"interval": "5m" | ||
} | ||
}, | ||
"input": { | ||
"search": { | ||
"request": { | ||
"indices": ["logs-*"], | ||
"body": { | ||
"query": { | ||
"bool": { | ||
"must_not": { | ||
"exists": { | ||
"field": "message" | ||
} | ||
}, | ||
"filter": { | ||
"range": { | ||
"@timestamp": { | ||
"gte": "now-5m" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"condition": { | ||
"compare": { | ||
"ctx.payload.hits.total": { | ||
"eq": 0 | ||
} | ||
} | ||
}, | ||
"actions": { | ||
"log_alert": { | ||
"logging": { | ||
"text": "Alert triggered: {{ctx.payload}}" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -119,3 +119,30 @@ | |
ansible.builtin.import_tasks: configure_cluster.yml | ||
run_once: true | ||
delegate_to: '{{ play_hosts | first }}' | ||
|
||
|
||
- name: Upload and apply Tenderdash log parsing pipeline | ||
ansible.builtin.uri: | ||
url: "{{ elasticsearch_url }}/logstash/_pipeline/process_proposal_pipeline" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be defined |
||
method: PUT | ||
body: "{{ lookup('file', 'files/pipelines/process_proposal_pipeline.json') }}" | ||
body_format: json | ||
user: "{{ elastic_username }}" | ||
password: "{{ elastic_password }}" | ||
when: inventory_hostname in groups['elasticsearch'] | ||
|
||
- name: Create Elasticsearch Watches | ||
ansible.builtin.uri: | ||
url: "{{ elasticsearch_url }}/_watcher/watch/{{ item.name }}" | ||
method: PUT | ||
body: "{{ lookup('file', item.file) }}" | ||
body_format: json | ||
user: "{{ elastic_username }}" | ||
password: "{{ elastic_password }}" | ||
loop: | ||
- { name: 'error_logs_watch', file: 'files/watches/error_logs_watch.json' } | ||
- { name: 'high_round_watch', file: 'files/watches/high_round_watch.json' } | ||
- { name: 'no_logs_watch', file: 'files/watches/no_logs_watch.json' } | ||
loop_control: | ||
label: "{{ item.name }}" | ||
when: inventory_hostname in groups['elasticsearch'] |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be defined in configuration