Skip to content

Commit

Permalink
Add successful timestamp to metrics script and fix num of lines at th…
Browse files Browse the repository at this point in the history
…e beginning of README (#316)
  • Loading branch information
satk0 committed Mar 14, 2024
1 parent 6e5ec94 commit 0af18ba
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ Table of exported metrics:
| logstash_info_status | counter | A metric with a constant '1' value labeled by status. |
| logstash_info_up | counter | A metric that returns 1 if the node is up, 0 otherwise. |
| logstash_stats_events_duration_millis | gauge | Duration of events processing in milliseconds. |
| logstash_stats_events_filtered | counter | Number of events filtered out. |
| logstash_stats_events_in | counter | Number of events received. |
| logstash_stats_events_out | counter | Number of events out. |
| logstash_stats_events_filtered | gauge | Number of events filtered out. |
| logstash_stats_events_in | gauge | Number of events received. |
| logstash_stats_events_out | gauge | Number of events out. |
| logstash_stats_events_queue_push_duration_millis | gauge | Duration of events push to queue in milliseconds. |
| logstash_stats_flow_filter_current | gauge | Current number of events in the filter queue. |
| logstash_stats_flow_filter_lifetime | counter | Lifetime number of events in the filter queue. |
Expand Down Expand Up @@ -345,9 +345,9 @@ Table of exported metrics:
| logstash_stats_pipeline_queue_events_queue_size | gauge | Number of events that the queue can accommodate |
| logstash_stats_pipeline_queue_max_size_in_bytes | gauge | Maximum size of given queue in bytes. |
| logstash_stats_pipeline_reloads_failures | counter | Number of failed pipeline reloads. |
| logstash_stats_pipeline_reloads_successes | counter | Number of successful pipeline reloads. |
| logstash_stats_pipeline_reloads_last_failure_timestamp | gauge | Timestamp of last failed pipeline reload. |
| logstash_stats_pipeline_reloads_last_success_timestamp | gauge | Timestamp of last successful pipeline reload. |
| logstash_stats_pipeline_reloads_successes | counter | Number of successful pipeline reloads. |
| logstash_stats_pipeline_up | gauge | Whether the pipeline is up or not. |
| logstash_stats_process_cpu_load_average_1m | gauge | Total 1m system load average. |
| logstash_stats_process_cpu_load_average_5m | gauge | Total 5m system load average. |
Expand Down
30 changes: 27 additions & 3 deletions scripts/add_metrics_to_readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function getMetrics() {
done
}

function failureConfigChange() {
function configChangeReload() {
local logstashCID
logstashCID=$( docker ps -a | grep 'logstash-exporter-logstash-1' | awk '{print $1}' )
local logstashConf
Expand All @@ -18,26 +18,50 @@ function failureConfigChange() {
local logstashPID
logstashPID=1

# *** create failing config ***

docker exec -it "$logstashCID" sh -c "echo 'Wrong Config' >> $logstashConf"

# reload logstash
docker exec -it "$logstashCID" sh -c "kill -1 $logstashPID"

# bring back previous config
# backup original config
# walk around with 'cp' to avoid replacing config inside container
docker exec "$logstashCID" sh -c "sed '\$d' $logstashConf > /tmp/prev_logstash.conf"
docker exec "$logstashCID" sh -c "cp /tmp/prev_logstash.conf $logstashConf"

# reload logstash
docker exec -it "$logstashCID" sh -c "kill -1 $logstashPID"

# *****************************

# *** create successful config ***

# delete lines of 'generator' config
docker exec "$logstashCID" sh -c "sed '2,7d' $logstashConf > /tmp/new_logstash.conf"
docker exec "$logstashCID" sh -c "cp /tmp/new_logstash.conf $logstashConf"

# reload logstash
docker exec -it "$logstashCID" sh -c "kill -1 $logstashPID"

# restore backup
docker exec "$logstashCID" sh -c "cp /tmp/prev_logstash.conf $logstashConf"

# reload logstash
docker exec -it "$logstashCID" sh -c "kill -1 $logstashPID"

# ********************************

}

failureConfigChange
configChangeReload

FILE=README.md
while IFS= read -r line; do LINES+=("$line"); done < $FILE

# remove number of lines from the beginning
LINES=("${LINES[@]:1}")

startLine=$(grep -n "^<!-- METRICS_TABLE_START -->" $FILE | awk -F: '{print $1}')
endLine=$(grep -n "^<!-- METRICS_TABLE_END -->" $FILE | awk -F: '{print $1}')

Expand Down

0 comments on commit 0af18ba

Please sign in to comment.