Metrics Wrapping
Downloads
Overview
This script is designed to process log files and generate metrics compatible with Prometheus Node Exporter. Metrics include averages, maximum values, and counts for specific log patterns. These metrics are written to a file in the Prometheus textfile collector format.
Features
- Processes multiple log files.
- Extracts metrics for averages, maximum values, and counts.
- Supports various log types such as request logs, performance logs, and session statistics.
- Outputs metrics in a format suitable for Prometheus monitoring.
Requirements
- Bash shell environment.
- Log files should be accessible in predefined paths.
- Prometheus Node Exporter with textfile collector enabled.
- Utilities:
awk,sort,head.
File Locations
Logs:
| Log Type | Default Path |
|---|---|
| RQLOG | /apps/log/tomcat/asgard-request.log |
| NSKPERF | /apps/log/tomcat/nskconnector4-perf.log |
| NSKSTAT | /apps/log/tomcat/nskconnector4-statistics.log |
| AMASTAT | /apps/log/tomcat/amaconnector-statistics.log |
| AMAPERF | /apps/log/tomcat/amaconnector-perf.log |
Metrics Output:
/apps/qcsupport/prometheus/textfile_collector/custom_metrics.prom
Metrics Processed
Request Logs (RQLOG):
create_bookingupdate_bookingretrieve_bookingfind_bookingsretrieve_pnr_externalcancel_bookingretrieve_seatmap
Performance Logs (NSKPERF):
nsk_find_bookingnsk_get_bookingnsk_clearnsk_cancel_bookingnsk_nminsk_save_ancillary_bookingnsk_retrieve_seatmapnsk_fare_overridensk_update_passengernsk_ancillary_price_changensk_manipulate_prices
AmaConnector Performance (AMAPERF):
ama_create_dummy_bookingama_save_ancillary_bookingama_nmiama_cancel_dummy_bookingama_create_bookingama_notify_bookings
Session Statistics (AMASTAT/NSKSTAT):
ama_sessionama_idlensk_sessionnsk_idle
Queue Metrics:
cfc_queuecpc_queue
Usage
- Ensure all required log files are present and accessible in the specified locations.
- Run the script:
/apps/qcsupport/prometheus/textfile_collector/metrics_wrapper.sh - Metrics will be written to:
/apps/qcsupport/prometheus/textfile_collector/custom_metrics.prom
Script Logic
- Log Processing:
- Each log file is checked for existence based on its type and current date-hour format (e.g.,
logname.YYYY-MM-DD-HH). - Metrics Calculation:
- For each metric pattern, the script calculates:
- Average: Mean value of matched patterns.
- Maximum: Maximum value of matched patterns.
- Count: Total occurrences of matched patterns.
- Output Metrics:
- Metrics are formatted as:
metric_name_avg{log="LOG_TYPE"} VALUE metric_name_max{log="LOG_TYPE"} VALUE metric_name_count{log="LOG_TYPE"} VALUE
Example Output
create_booking_avg{log="RQLOG"} 12.3
create_booking_max{log="RQLOG"} 45
create_booking_count{log="RQLOG"} 67
Troubleshooting
- Missing Log Files:
- If a log file is not found, the script will skip it and print a warning message.
- Incorrect Metrics:
- Ensure the log format matches the patterns defined in the script.
- Empty Metrics File:
- Verify that logs contain relevant data for the specified time frame.
Customization
- Modify the
LOGSandMETRICSarrays to add or update log file paths and patterns. - Change the output file path by editing the
METRICS_FILEvariable.
Contact
For further assistance, contact your system administrator or DevOps team.
Changelog
| Date | Author | Message |
|---|---|---|
| 2026-02-25 | aresnikowa | Merge remote-tracking branch 'origin/master' |