Skip to content

Metrics Wrapping

Downloads

metrics-wrapper-script.git

Downlaod script

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_booking
  • update_booking
  • retrieve_booking
  • find_bookings
  • retrieve_pnr_external
  • cancel_booking
  • retrieve_seatmap

Performance Logs (NSKPERF):

  • nsk_find_booking
  • nsk_get_booking
  • nsk_clear
  • nsk_cancel_booking
  • nsk_nmi
  • nsk_save_ancillary_booking
  • nsk_retrieve_seatmap
  • nsk_fare_override
  • nsk_update_passenger
  • nsk_ancillary_price_change
  • nsk_manipulate_prices

AmaConnector Performance (AMAPERF):

  • ama_create_dummy_booking
  • ama_save_ancillary_booking
  • ama_nmi
  • ama_cancel_dummy_booking
  • ama_create_booking
  • ama_notify_bookings

Session Statistics (AMASTAT/NSKSTAT):

  • ama_session
  • ama_idle
  • nsk_session
  • nsk_idle

Queue Metrics:

  • cfc_queue
  • cpc_queue

Usage

  1. Ensure all required log files are present and accessible in the specified locations.
  2. Run the script:
    /apps/qcsupport/prometheus/textfile_collector/metrics_wrapper.sh
    
  3. Metrics will be written to:
    /apps/qcsupport/prometheus/textfile_collector/custom_metrics.prom
    

Script Logic

  1. Log Processing:
  2. Each log file is checked for existence based on its type and current date-hour format (e.g., logname.YYYY-MM-DD-HH).
  3. Metrics Calculation:
  4. 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.
  5. Output Metrics:
  6. 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 LOGS and METRICS arrays to add or update log file paths and patterns.
  • Change the output file path by editing the METRICS_FILE variable.

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'