من توی یه شرکت فروش بلیط سینما کار میکنم به اسم gi...

Created on: October 15, 2025

Answered using GPT-5 Thinking by Chat01

Question

من توی یه شرکت فروش بلیط سینما کار میکنم به اسم gisheh7 یه سازمان بزرگ وجود داره به اسم سمفا که به شرکت های مختلف مثل شرکت ما مجوز فروش بلیط میده. طبیعتا باید یسری اطلاعات ما مدام از سمفا بگیریم ینی یسری api باید بگیریم و بفرستیم. مثلا اینکه چه صندلی هاییی پره و خالیه و چی فروش رفت و چی کنسل شد و همه اینارو باید هم بدیم هم بگیریم. مثلا یه شرکت دیگه مثل سینما تیکت یکی فروش بلیطشو کنسل میکنه باید اون کنسلی برای ما هم بیاد ک بفهمیم فلان صندلی خالی شده. من باید یه داشبورد بزنم توی گرافانا برای مانتورینگ کارای سمفا. نمیدونم چه بخشایی باید داشته باشه چه چیزایی رو نشون بده و چه متریک هایی نیازه. خلاقیت و دفت میخواد دقیق بهم بگو چه پنل هایی به چه اسمی لازمه و هر پنل دقیقا چی بهمون نشون بده خوب و مفیده

این متریک های منه

Name Type Description
EXTERNAL_PAYMENT_COMPONENT_TOKEN_seconds_count counter Count of events that have been observed for the base metric ( )
Select
EXTERNAL_PAYMENT_COMPONENT_TOKEN_seconds_max gauge
Select
EXTERNAL_PAYMENT_COMPONENT_TOKEN_seconds_sum counter Total sum of all observed values for the base metric ( )
Select
MELLAT_REFUND_REPORT_RESPONSE_seconds_count counter Count of events that have been observed for the base metric ( )
Select
MELLAT_REFUND_REPORT_RESPONSE_seconds_max gauge
Select
MELLAT_REFUND_REPORT_RESPONSE_seconds_sum counter Total sum of all observed values for the base metric ( )
Select
application_ready_time_seconds gauge Time taken for the application to be ready to service requests
Select
application_started_time_seconds gauge Time taken to start the application
Select
discount_response_time_seconds_count counter Count of events that have been observed for the base metric ( )
Select
discount_response_time_seconds_max gauge
Select
discount_response_time_seconds_sum counter Total sum of all observed values for the base metric ( )
Select
discount_usage_counter_total
Select
disk_free_bytes gauge Usable space for path
Select
disk_total_bytes gauge Total space for path
Select
executor_active_threads gauge The approximate number of threads that are actively executing tasks
Select
executor_completed_tasks_total
Select
executor_pool_core_threads gauge The core number of threads for the pool
Select
executor_pool_max_threads gauge The maximum allowed number of threads in the pool
Select
executor_pool_size_threads gauge The current number of threads in the pool
Select
executor_queue_remaining_tasks gauge The number of additional elements that this queue can ideally accept without blocking
Select
executor_queued_tasks gauge The approximate number of tasks that are queued for execution
Select
external_component_seconds_count counter Count of events that have been observed for the base metric (Duration of repository invocations)
Select
external_component_seconds_max gauge Duration of repository invocations
Select
external_component_seconds_sum counter Total sum of all observed values for the base metric (Duration of repository invocations)
Select
external_service_seconds_count counter Count of events that have been observed for the base metric ( )
Select
external_service_seconds_max gauge
Select
external_service_seconds_sum counter Total sum of all observed values for the base metric ( )
Select
get_daily_refunds_response_time_seconds_count counter Count of events that have been observed for the base metric ( )
Select
get_daily_refunds_response_time_seconds_max gauge
Select
get_daily_refunds_response_time_seconds_sum counter Total sum of all observed values for the base metric ( )
Select
hikaricp_connections gauge Total connections
Select
hikaricp_connections_acquire_seconds_count counter Count of events that have been observed for the base metric (Connection acquire time)
Select
hikaricp_connections_acquire_seconds_max gauge Connection acquire time
Select
hikaricp_connections_acquire_seconds_sum counter Total sum of all observed values for the base metric (Connection acquire time)
Select
hikaricp_connections_active gauge Active connections
Select
hikaricp_connections_creation_seconds_count counter Count of events that have been observed for the base metric (Connection creation time)
Select
hikaricp_connections_creation_seconds_max gauge Connection creation time
Select
hikaricp_connections_creation_seconds_sum counter Total sum of all observed values for the base metric (Connection creation time)
Select
hikaricp_connections_idle gauge Idle connections
Select
hikaricp_connections_max gauge Max connections
Select
hikaricp_connections_min gauge Min connections
Select
hikaricp_connections_pending gauge Pending threads
Select
hikaricp_connections_timeout_total
Select
hikaricp_connections_usage_seconds_count counter Count of events that have been observed for the base metric (Connection usage time)
Select
hikaricp_connections_usage_seconds_max gauge Connection usage time
Select
hikaricp_connections_usage_seconds_sum counter Total sum of all observed values for the base metric (Connection usage time)
Select
http_server_requests_active_seconds_active_count
Select
http_server_requests_active_seconds_bucket counter Cumulative counters for the observation buckets ( )
Select
http_server_requests_active_seconds_duration_sum
Select
http_server_requests_active_seconds_max gauge
Select
http_server_requests_seconds_bucket counter Cumulative counters for the observation buckets ( )
Select
http_server_requests_seconds_count counter (histogram) Count of events that have been observed for the histogram metric ( )
Select
http_server_requests_seconds_max gauge
Select
http_server_requests_seconds_sum counter (histogram) Total sum of all observed values for the histogram metric ( )
Select
invalid_refund_requests_total
Select
jdbc_connections_active gauge Current number of active connections that have been allocated from the data source.
Select
jdbc_connections_idle gauge Number of established but idle connections.
Select
jdbc_connections_max gauge Maximum number of active connections that can be allocated at the same time.
Select
jdbc_connections_min gauge Minimum number of idle connections in the pool.
Select
jvm_buffer_count_buffers gauge An estimate of the number of buffers in the pool
Select
jvm_buffer_memory_used_bytes gauge An estimate of the memory that the Java virtual machine is using for this buffer pool
Select
jvm_buffer_total_capacity_bytes gauge An estimate of the total capacity of the buffers in this pool
Select
jvm_classes_loaded_classes gauge The number of classes that are currently loaded in the Java virtual machine
Select
jvm_classes_unloaded_classes_total
Select
jvm_compilation_time_ms_total
Select
jvm_gc_concurrent_phase_time_seconds_count counter Count of events that have been observed for the base metric (Time spent in concurrent phase)
Select
jvm_gc_concurrent_phase_time_seconds_max gauge Time spent in concurrent phase
Select
jvm_gc_concurrent_phase_time_seconds_sum counter Total sum of all observed values for the base metric (Time spent in concurrent phase)
Select
jvm_gc_live_data_size_bytes gauge Size of long-lived heap memory pool after reclamation
Select
jvm_gc_max_data_size_bytes gauge Max size of long-lived heap memory pool
Select
jvm_gc_memory_allocated_bytes_total
Select
jvm_gc_memory_promoted_bytes_total
Select
jvm_gc_overhead gauge An approximation of the percent of CPU time used by GC activities over the last lookback period or since monitoring began, whichever is shorter, in the range [0..1]
Select
jvm_gc_overhead_percent gauge An approximation of the percent of CPU time used by GC activities over the last lookback period or since monitoring began, whichever is shorter, in the range [0..1]
Select
jvm_gc_pause_seconds_count counter Count of events that have been observed for the base metric (Time spent in GC pause)
Select
jvm_gc_pause_seconds_max gauge Time spent in GC pause
Select
jvm_gc_pause_seconds_sum counter Total sum of all observed values for the base metric (Time spent in GC pause)
Select
jvm_info gauge JVM version info
Select
jvm_memory_committed_bytes gauge The amount of memory in bytes that is committed for the Java virtual machine to use
Select
jvm_memory_max_bytes gauge The maximum amount of memory in bytes that can be used for memory management
Select
jvm_memory_usage_after_gc gauge The percentage of long-lived heap pool used after the last GC event, in the range [0..1]
Select
jvm_memory_usage_after_gc_percent gauge The percentage of long-lived heap pool used after the last GC event, in the range [0..1]
Select
jvm_memory_used_bytes gauge The amount of used memory
Select
jvm_threads_daemon_threads gauge The current number of live daemon threads
Select
jvm_threads_live_threads gauge The current number of live threads including both daemon and non-daemon threads
Select
jvm_threads_peak_threads gauge The peak live thread count since the Java virtual machine started or peak was reset
Select
jvm_threads_started_threads_total
Select
jvm_threads_states_threads gauge The current number of threads
Select
lettuce_command_completion_seconds_count counter Count of events that have been observed for the base metric (Latency between command send and command completion (complete response received)
Select
lettuce_command_completion_seconds_max gauge Latency between command send and command completion (complete response received
Select
lettuce_command_completion_seconds_sum counter Total sum of all observed values for the base metric (Latency between command send and command completion (complete response received)
Select
lettuce_command_firstresponse_seconds_count counter Count of events that have been observed for the base metric (Latency between command send and first response (first response received))
Select
lettuce_command_firstresponse_seconds_max gauge Latency between command send and first response (first response received)
Select
lettuce_command_firstresponse_seconds_sum counter Total sum of all observed values for the base metric (Latency between command send and first response (first response received))
Select
logback_events_total
Select
process_cpu_time_ns_total
Select
process_cpu_usage gauge The "recent cpu usage" for the Java Virtual Machine process
Select
process_files_max_files gauge The maximum file descriptor count
Select
process_files_open_files gauge The open file descriptor count
Select
process_start_time_seconds gauge Start time of the process since unix epoch.
Select
process_uptime_seconds
gauge
The uptime of the Java virtual machine
Select
refund_requests_total

Select
refund_response_time_seconds_count

Select
refund_response_time_seconds_max

Select
refund_response_time_seconds_sum

Select
reserve_ticket_response_time_seconds_count
counter
Count of events that have been observed for the base metric ( )
Select
reserve_ticket_response_time_seconds_max
gauge

Select
reserve_ticket_response_time_seconds_sum
counter
Total sum of all observed values for the base metric ( )
Select
scrape_duration_seconds

Select
scrape_samples_post_metric_relabeling

Select
scrape_samples_scraped

Select
scrape_series_added

Select
signup_count_total

Select
sms_kavenegar_total

Select
sms_niksms_total

Select
sms_sent_total

Select
spring_data_repository_invocations_seconds_count
counter
Count of events that have been observed for the base metric (Duration of repository invocations)
Select
spring_data_repository_invocations_seconds_max
gauge
Duration of repository invocations
Select
spring_data_repository_invocations_seconds_sum
counter
Total sum of all observed values for the base metric (Duration of repository invocations)
Select
spring_security_authorizations_active_seconds_active_count

Select
spring_security_authorizations_active_seconds_duration_sum

Select
spring_security_authorizations_active_seconds_max
gauge

Select
spring_security_authorizations_seconds_count
counter
Count of events that have been observed for the base metric ( )
Select
spring_security_authorizations_seconds_max
gauge

Select
spring_security_authorizations_seconds_sum
counter
Total sum of all observed values for the base metric ( )
Select
spring_security_filterchains_JwtAuthFilter_after_total

Select
spring_security_filterchains_JwtAuthFilter_before_total

Select
spring_security_filterchains_access_exceptions_after_total

Select
spring_security_filterchains_access_exceptions_before_total

Select
spring_security_filterchains_active_seconds_active_count

Select
spring_security_filterchains_active_seconds_duration_sum

Select
spring_security_filterchains_active_seconds_max
gauge

Select
spring_security_filterchains_authentication_anonymous_after_total

Select
spring_security_filterchains_authentication_anonymous_before_total

Select
spring_security_filterchains_authorization_after_total

Select
spring_security_filterchains_authorization_before_total

Select
spring_security_filterchains_context_async_after_total

Select
spring_security_filterchains_context_async_before_total

Select
spring_security_filterchains_context_holder_after_total

Select
spring_security_filterchains_context_holder_before_total

Select
spring_security_filterchains_context_servlet_after_total

Select
spring_security_filterchains_context_servlet_before_total

Select
spring_security_filterchains_cors_after_total

Select
spring_security_filterchains_cors_before_total

Select
spring_security_filterchains_header_after_total

Select
spring_security_filterchains_header_before_total

Select
spring_security_filterchains_logout_after_total

Select
spring_security_filterchains_logout_before_total

Select
spring_security_filterchains_requestcache_after_total

Select
spring_security_filterchains_requestcache_before_total

Select
spring_security_filterchains_seconds_count
counter
Count of events that have been observed for the base metric ( )
Select
spring_security_filterchains_seconds_max
gauge

Select
spring_security_filterchains_seconds_sum
counter
Total sum of all observed values for the base metric ( )
Select
spring_security_filterchains_session_management_after_total

Select
spring_security_filterchains_session_management_before_total

Select
spring_security_filterchains_session_urlencoding_after_total

Select
spring_security_filterchains_session_urlencoding_before_total

Select
spring_security_http_secured_requests_active_seconds_active_count

Select
spring_security_http_secured_requests_active_seconds_duration_sum

Select
spring_security_http_secured_requests_active_seconds_max
gauge

Select
spring_security_http_secured_requests_seconds_count
counter
Count of events that have been observed for the base metric ( )
Select
spring_security_http_secured_requests_seconds_max
gauge

Select
spring_security_http_secured_requests_seconds_sum
counter
Total sum of all observed values for the base metric ( )
Select
system_cpu_count
gauge
The number of processors available to the Java virtual machine
Select
system_cpu_usage
gauge
The "recent cpu usage" of the system the application is running in
Select
system_load_average_1m
gauge
The sum of the number of runnable entities queued to available processors and the number of runnable entities running on the available processors averaged over a period of time
Select
tasks_scheduled_execution_active_seconds_active_count

Select
tasks_scheduled_execution_active_seconds_duration_sum

Select
tasks_scheduled_execution_active_seconds_max
gauge

Select
tasks_scheduled_execution_seconds_count
counter
Count of events that have been observed for the base metric ( )
Select
tasks_scheduled_execution_seconds_max
gauge

Select
tasks_scheduled_execution_seconds_sum
counter
Total sum of all observed values for the base metric ( )
Select
tickets_count_total

Select
tomcat_sessions_active_current_sessions
gauge

Select
tomcat_sessions_active_max_sessions
gauge

Select
tomcat_sessions_alive_max_seconds
gauge

Select
tomcat_sessions_created_sessions_total

Select
tomcat_sessions_expired_sessions_total

Select
tomcat_sessions_rejected_sessions_total

قشنگ بگو مرحله مرحله چیکار کنم و توی داشبوردم چه پنل هایی داشته باشم و هر پنل چی رو نشون بده و چه متریکی استفاده میکنه. یعنی کوئری هر پنل رو قشنگ بنویس. خلاصه کامل و جامع باشه و دقییق بهم بگو چیکار کنم. اسم پنل ها و همه چی هم بگو

Thought

Crafting Grafana Dashboards

The user wants a guide for Grafana dashboards to monitor SAMFA integration in cinema ticketing. We'll focus on incorporating their existing Prometheus-style metrics like *_seconds_count, sum, and max, using PromQL queries for things like rate/avg/latency. We can approximate gaps with telemetry from endpoints like reserve_ticket or refund.

Building Grafana Dashboards

The user needs step-by-step instructions for creating detailed Grafana panels like an overview, API health, transaction funnels, and error ratios. Beyond Prometheus metrics, I can suggest custom counters/gauges (e.g., for seat consistency). PromQL queries will be key for queries like rate() and sum by (status, uri).

Crafting a Persian-language Grafana Guide

The user wants a detailed guide in Persian for Grafana, including PromQL queries. I'll keep the tone clear and chatty as requested. The structure will include instrumentation checks, labels, and Grafana data sources. Each panel will have a name, query, and description, and we’ll use macros like $_rate_interval. I'll suggest labels like result=success|error.

Designing SAMFA Integration Panels

For SAMFA, I'll use Spring Boot's Micrometer metrics, like http_server_requests_seconds_count, with labels such as method, status, and uri. For latency, we might use external_service_seconds if it represents remote call durations to SAMFA. For success rates, I'll need to check endpoints—http_server_requests represents server-side metrics, so pairing with external_service_seconds_* might help track client-side call errors.

Designing Dashboard for SAMFA Integration

For the SAMFA integration dashboard, I'll ensure clarity with sections and panels.

  1. Service Overview / SLO: RPS, latency, and error rates for key endpoints like reserve, refund, and get seats.
  2. Ticketing Flow Funnel: Requests → Reserve → Payment → Issue → Confirmation → SMS → SAMFA sync, using tickets and refund counters.
  3. SAMFA Health: Track latency and success rates for SAMFA calls and webhooks.
  4. Payments and Refunds: Latency monitoring and counts for Mellat gateway and refund metrics.
  5. Database & JVM Monitoring: Hikaricp, jdbc metrics, and JVM stats.

Grafana queries and panel names will be in both Persian and English, and I'll express the relevant thresholds and metrics in PromQL.

Thought for 1m 5s

Answer

خیلی خوب—بیایم یک «داشبورد مانیتورینگ سمفا» بسازیم که هم وضعیت فنی سرویس‌هات رو پوشش بده، هم سلامت یکپارچگی با «سمفا» و هم KPIهای بیزنسی (فروش/کنسلی). پایین‌تر همه‌چیز رو مرحله‌به‌مرحله نوشتم: از متغیرهای داشبورد و چیدمان پنل‌ها تا کوئری دقیق هر پنل (PromQL). هرجا متریک لازم رو نداری، آخر کار «پیشنهاد متریک‌های تکمیلی» گذاشتم که اضافه کنی تا تصویر کامل‌تر بشه.


1) گام‌های اولیه (Grafana + Prometheus)

  1. Data Source: پرومتئوس رو به عنوان Data Source ست کن.
  2. Variables در Grafana:
    • $job:
      promql
      label_values(process_uptime_seconds, job)
    • $instance:
      promql
      label_values(process_uptime_seconds{job="$job"}, instance)
    • $samfa_uri: مسیرهای وب‌هوک/کال‌بک سمفا روی سرور شما (اگر وجود دارد):
      promql
      label_values(http_server_requests_seconds_count{uri=~"/samfa/.+"}, uri)
    • $reserve_uri: مسیر رزرو (فرض: /api/v1/reserve را متناسب با سیستم‌تان بگذارید):
      promql
      label_values(http_server_requests_seconds_count{uri=~".*reserve.*"}, uri)
    • $payment_gateway: اگر لیبل دارید (مثلاً gateway="mellat")، وگرنه این متغیر اختیاری است:
      promql
      label_values(EXTERNAL_PAYMENT_COMPONENT_TOKEN_seconds_count, gateway)

نکته: در تمام کوئری‌ها از ماکروهای Grafana استفاده می‌کنیم: $__rate_interval, $__interval, $__range تا مقیاس‌پذیر باشد.


2) ساختار داشبورد

پیشنهاد: یک داشبورد اصلی به نام «سمفا – پایش یکپارچگی و فروش (GiSheh7)» با این سکشن‌ها:

  1. نمای کلی (SLO/SLA Overview)
  2. جریان فروش و قیف تراکنش
  3. یکپارچگی سمفا (Outbound/Inbound)
  4. پرداخت و استرداد (Mellat/Refunds)
  5. سلامت API داخلی (HTTP Server)
  6. پایگاه‌داده و صف/ThreadPool
  7. JVM و سیستم
  8. امنیت/احراز (Spring Security)

پایین‌تر، برای هر سکشن نام پنل، هدف و کوئری دقیق رو گذاشتم.


سکشن 1) نمای کلی (SLO/SLA Overview)

1. «درخواست بر ثانیه (RPS) – کل سرویس»

  • نوع پنل: Time series
  • هدف: بار کلی ورودی
  • کوئری:
    promql
    sum by (job) ( rate(http_server_requests_seconds_count{job="$job"}[$__rate_interval]) )

2. «میانگین تأخیر رزرو (Avg Latency – Reserve)»

  • نوع: Stat (همراه با اسپارکلاین)
  • هدف: میانگین تأخیر endpoint رزرو
  • کوئری:
    promql
    sum(rate(reserve_ticket_response_time_seconds_sum[$__rate_interval])) / sum(rate(reserve_ticket_response_time_seconds_count[$__rate_interval]))

3. «p95 تأخیر کل سرویس (HTTP)»

  • نوع: Stat
  • هدف: p95 برای تمام درخواست‌های HTTP
  • کوئری:
    promql
    histogram_quantile(0.95, sum by (le) ( rate(http_server_requests_seconds_bucket{job="$job"}[$__rate_interval]) ) )

4. «نرخ خطا (۵xx)»

  • نوع: Stat
  • هدف: درصد خطای 5xx
  • کوئری:
    promql
    100 * ( sum(rate(http_server_requests_seconds_count{job="$job", status=~"5.."}[$__rate_interval])) ) / sum(rate(http_server_requests_seconds_count{job="$job"}[$__rate_interval]))

سکشن 2) جریان فروش و قیف تراکنش

ایده: وضعیت «رزرو → پرداخت → صدور بلیت → SMS → (در صورت لغو) استرداد» را ببین.

5. «رزروهای انجام‌شده (Throughput)»

  • نوع: Stat
  • کوئری (تعداد بر ثانیه):
    promql
    sum(rate(reserve_ticket_response_time_seconds_count[$__rate_interval]))

6. «میانگین تأخیر پاسخ رزرو»

  • نوع: Time series
  • کوئری:
    promql
    sum by ($reserve_uri)( rate(reserve_ticket_response_time_seconds_sum{uri="$reserve_uri"}[$__rate_interval]) ) / sum by ($reserve_uri)( rate(reserve_ticket_response_time_seconds_count{uri="$reserve_uri"}[$__rate_interval]) )

7. «بلیت‌های صادرشده امروز»

  • نوع: Stat
  • کوئری (تجمع روزانه):
    promql
    increase(tickets_count_total[$__range])

اگر tickets_count_total سراسری است، می‌تونی بر اساس job/instance هم group کنی.

8. «SMSهای ارسال‌شده امروز»

  • نوع: Bar gauge
  • کوئری:
    promql
    increase(sms_sent_total[$__range])

9. «درخواست‌های استرداد (Refund) امروز»

  • نوع: Stat (قرمز/هشدار اگر جهش غیرعادی)
  • کوئری:
    promql
    increase(refund_requests_total[$__range])

10. «درخواست‌های استرداد نامعتبر (Invalid Refunds)»

  • نوع: Stat
  • کوئری:
    promql
    increase(invalid_refund_requests_total[$__range])

پنل ترکیبی قیف: چهار Stat کنار هم
«رزروها» = 5 | «بلیت‌های صادرشده» = 7 | «SMS ارسال‌شده» = 8 | «Refund» = 9
اختلاف زیاد بین رزرو و بلیت صادرشده ⇒ گلوگاه پرداخت. اختلاف زیاد بین بلیت صادرشده و SMS ⇒ مشکل سرویس پیامک.


سکشن 3) یکپارچگی سمفا (Outbound/Inbound)

فرض می‌کنیم outbound callها با external_service_seconds_* برچسبی مثل service="samfa" دارند. اگر ندارید، همین متریک‌ها را با چنین لیبل‌هایی اضافه کنید.

11. «تعداد تماس‌های خروجی به سمفا (RPS)»

  • نوع: Time series
  • کوئری:
    promql
    sum by (service) ( rate(external_service_seconds_count{service="samfa"}[$__rate_interval]) )

12. «میانگین تأخیر تماس‌های خروجی به سمفا»

  • نوع: Time series
  • کوئری:
    promql
    sum(rate(external_service_seconds_sum{service="samfa"}[$__rate_interval])) / sum(rate(external_service_seconds_count{service="samfa"}[$__rate_interval]))

13. «بیشینه تأخیر سمفا (Max over 5m)»

  • نوع: Stat
  • کوئری:
    promql
    max_over_time(external_service_seconds_max{service="samfa"}[5m])

14. «نرخ خطای وب‌هوک‌های ورودی از سمفا»

  • نوع: Stat
  • هدف: وب‌هوک‌هایی که سمفا به سرویس شما می‌زند (مسیرهای /samfa/*)
  • کوئری:
    promql
    100 * sum(rate(http_server_requests_seconds_count{uri=~"/samfa/.+", status=~"5.."}[$__rate_interval])) / sum(rate(http_server_requests_seconds_count{uri=~"/samfa/.+"}[$__rate_interval]))

15. «p95 تأخیر وب‌هوک سمفا»

  • نوع: Time series
  • کوئری:
    promql
    histogram_quantile(0.95, sum by (le) ( rate(http_server_requests_seconds_bucket{uri=~"/samfa/.+"}[$__rate_interval]) ) )

16. «صف/تاخیر همگام‌سازی رزرو/لغو (Backlog Proxy)»

  • نوع: Time series
  • هدف: اگر همگام‌سازی با job/queue انجام می‌شود، طول صف را ببین
  • کوئری (تقریبی با ThreadPool):
    promql
    sum(executor_queued_tasks)
    و ظرفیت با:
    promql
    sum(executor_queue_remaining_tasks)

اگر واقعاً job اختصاصی دارید، متریک‌های اختصاصی queue length/lag اضافه کنید (در انتهای پاسخ پیشنهاد دادم).


سکشن 4) پرداخت و استرداد (Mellat/Refunds)

17. «RPS توکن پرداخت (Mellat)»

  • نوع: Time series
  • کوئری:
    promql
    sum(rate(EXTERNAL_PAYMENT_COMPONENT_TOKEN_seconds_count[$__rate_interval]))

18. «میانگین تأخیر گرفتن توکن پرداخت»

  • نوع: Time series
  • کوئری:
    promql
    sum(rate(EXTERNAL_PAYMENT_COMPONENT_TOKEN_seconds_sum[$__rate_interval])) / sum(rate(EXTERNAL_PAYMENT_COMPONENT_TOKEN_seconds_count[$__rate_interval]))

19. «بیشینه تأخیر توکن پرداخت (5m max)»

  • نوع: Stat
  • کوئری:
    promql
    max_over_time(EXTERNAL_PAYMENT_COMPONENT_TOKEN_seconds_max[5m])

20. «RPS گزارش استرداد Mellat»

  • نوع: Time series
  • کوئری:
    promql
    sum(rate(MELLAT_REFUND_REPORT_RESPONSE_seconds_count[$__rate_interval]))

21. «میانگین تأخیر گزارش استرداد Mellat»

  • نوع: Time series
  • کوئری:
    promql
    sum(rate(MELLAT_REFUND_REPORT_RESPONSE_seconds_sum[$__rate_interval])) / sum(rate(MELLAT_REFUND_REPORT_RESPONSE_seconds_count[$__rate_interval]))

22. «میانگین تأخیر پاسخ Refund داخلی»

  • نوع: Time series
  • کوئری:
    promql
    sum(rate(refund_response_time_seconds_sum[$__rate_interval])) / sum(rate(refund_response_time_seconds_count[$__rate_interval]))

سکشن 5) سلامت API داخلی (HTTP Server)

23. «RPS بر اساس مسیر»

  • نوع: Time series (Legend بر اساس uri)
  • کوئری:
    promql
    sum by (uri) ( rate(http_server_requests_seconds_count{job="$job"}[$__rate_interval]) )

24. «p50/p90/p99 تأخیر کل»

  • نوع: Time series (سه سری جدا)
  • کوئری‌ها:
    promql
    histogram_quantile(0.5, sum by (le) (rate(http_server_requests_seconds_bucket{job="$job"}[$__rate_interval])) )
    promql
    histogram_quantile(0.9, sum by (le) (rate(http_server_requests_seconds_bucket{job="$job"}[$__rate_interval])) )
    promql
    histogram_quantile(0.99, sum by (le) (rate(http_server_requests_seconds_bucket{job="$job"}[$__rate_interval])) )

25. «Error Ratio به تفکیک کلاس وضعیت»

  • نوع: Bar gauge
  • کوئری:
    promql
    sum by (status) (rate(http_server_requests_seconds_count{status=~"5.."}[$__rate_interval])) / sum by (status) (rate(http_server_requests_seconds_count[$__rate_interval]))

26. «فعالیت درخواست‌های درحال پردازش (In-Flight)»

  • نوع: Time series
  • کوئری:
    promql
    sum(http_server_requests_active_seconds_active_count)

سکشن 6) پایگاه‌داده و صف/ThreadPool

27. «وضعیت Connection Pool (Hikari)»

  • نوع: Time series (legend: active/idle/max/pending)
  • کوئری‌ها:
    promql
    avg(hikaricp_connections_active)
    promql
    avg(hikaricp_connections_idle)
    promql
    avg(hikaricp_connections_max)
    promql
    avg(hikaricp_connections_pending)

28. «زمان اکتساب کانکشن (Acquire) – میانگین»

  • نوع: Time series
  • کوئری:
    promql
    sum(rate(hikaricp_connections_acquire_seconds_sum[$__rate_interval])) / sum(rate(hikaricp_connections_acquire_seconds_count[$__rate_interval]))

29. «تاخیر دسترسی به Redis (Lettuce) – Avg/Max»

  • نوع: Time series
  • کوئری Avg:
    promql
    sum(rate(lettuce_command_completion_seconds_sum[$__rate_interval])) / sum(rate(lettuce_command_completion_seconds_count[$__rate_interval]))
  • کوئری Max (5m):
    promql
    max_over_time(lettuce_command_completion_seconds_max[5m])

30. «ThreadPool Load»

  • نوع: Time series
  • کوئری‌ها:
    • Threads فعال:
      promql
      sum(executor_active_threads)
    • اندازه Pool:
      promql
      sum(executor_pool_size_threads)
    • صف در انتظار:
      promql
      sum(executor_queued_tasks)

سکشن 7) JVM و سیستم

31. «Memory Heap – استفاده/حداکثر»

  • نوع: Time series
  • کوئری‌ها:
    promql
    sum(jvm_memory_used_bytes{area="heap"})
    promql
    sum(jvm_memory_max_bytes{area="heap"})

32. «GC Pause (p95)»

  • نوع: Time series
  • کوئری:
    promql
    1000 * histogram_quantile(0.95, sum by (le) (rate(jvm_gc_pause_seconds_bucket[$__rate_interval])) )
    (ms)

33. «CPU مصرفی پردازش»

  • نوع: Time series
  • کوئری:
    promql
    avg(process_cpu_usage)

34. «Load Average (1m)»

  • نوع: Time series
  • کوئری:
    promql
    avg(system_load_average_1m)

35. «Disk Free/Total»

  • نوع: Time series
  • کوئری‌ها:
    promql
    sum(disk_free_bytes)
    promql
    sum(disk_total_bytes)

سکشن 8) امنیت/احراز هویت

36. «زمان پاسخ احراز (Avg)»

  • نوع: Time series
  • کوئری:
    promql
    sum(rate(spring_security_authorizations_seconds_sum[$__rate_interval])) / sum(rate(spring_security_authorizations_seconds_count[$__rate_interval]))

37. «وب‌فلوهای Security (FilterChains) – خطا/مدت»

  • نوع: Time series
  • کوئری Max طی 5m:
    promql
    max_over_time(spring_security_filterchains_seconds_max[5m])
  • تعداد رویدادها:
    promql
    sum(rate(spring_security_filterchains_seconds_count[$__rate_interval]))

3) آلارم‌های پیشنهادی (Rules)

  1. خطای وب‌هوک سمفا > ۱٪ برای ۱۰ دقیقه

    promql
    ( sum(rate(http_server_requests_seconds_count{uri=~"/samfa/.+", status=~"5.."}[10m])) ) / sum(rate(http_server_requests_seconds_count{uri=~"/samfa/.+"}[10m])) > 0.01
  2. p95 تأخیر تماس با سمفا > ۲ ثانیه برای ۱۰ دقیقه

    promql
    histogram_quantile(0.95, sum by (le) (rate(http_server_requests_seconds_bucket{uri=~"/samfa/.+"}[10m])) ) > 2
  3. ThreadPool صف > ۱۰۰ برای ۵ دقیقه

    promql
    avg_over_time(executor_queued_tasks[5m]) > 100
  4. Hikari Pending > 0 برای ۵ دقیقه

    promql
    avg_over_time(hikaricp_connections_pending[5m]) > 0
  5. Error Ratio کل > ۲٪ برای ۱۰ دقیقه

    promql
    ( sum(rate(http_server_requests_seconds_count{status=~"5.."}[10m])) ) / sum(rate(http_server_requests_seconds_count[10m])) > 0.02

4) نکات تفسیر و بهترین‌عمل

  • برای «میانگین» از sum(rate(_sum)) / sum(rate(_count)) استفاده کردیم.
  • برای «p50/p90/p99» فقط جایی که *_bucket داری (مثل http_server_requests_seconds_bucket) از histogram_quantile استفاده کن.
  • حتماً برای مسیرهای سمفا (/samfa/*) و رزرو (/reserve*) label درست بذار تا فیلتر کردن راحت باشه.
  • Annotations منتشر کن: زمان deploy (با application_started_time_seconds) و قطعی‌های زیرساخت.

5) شکاف‌ها و «متریک‌های تکمیلی» (پیشنهادی برای پوشش کامل سناریوی سمفا)

برای سناریوی «وقتی CinemaTicket کنسل می‌کند، صندلی برای شما آزاد شود»، لازم است چند متریک دامنه‌محور اضافه شوند تا سازگاری موجودی صندلی را ببینی:

  1. seat_sync_events_total{source="samfa"|"local", type="reserve"|"cancel"}

    • شمارش رویدادهای سنک (ورودی سمفا و داخلی خودت).
  2. seat_sync_lag_seconds{flow="cancel"|"reserve"} (gauge)

    • اختلاف زمان بین ثبت کنسلی در سمفا تا اعمال آن در سیستم شما.
  3. seats_inconsistent_total (gauge)

    • تعداد صندلی‌هایی که وضعیتشان در سیستم شما با وضعیت اعلامی سمفا مغایرت دارد (Job شبانه یا ساعتی چک کند).
  4. payment_result_total{gateway="mellat", result="success"|"failed"|"timeout"}

    • برای قیف تراکنش و تشخیص گلوگاه‌ها.
  5. webhook_delivery_total{endpoint="/samfa/...", result="2xx|5xx|timeout"}

    • کیفیت دریافت و پردازش وب‌هوک‌های سمفا.

با این متریک‌ها می‌تونی یک پنل «سازگاری صندلی‌ها» بسازی:

  • Inconsistency Today:
    promql
    max_over_time(seats_inconsistent_total[$__range])
  • Lag توزیع کنسلی p95:
    promql
    histogram_quantile(0.95, sum by (le) (rate(seat_sync_lag_seconds_bucket{flow="cancel"}[$__rate_interval])) )
    (اگر bucket اضافه کنی. در غیر این صورت میانگین با gauge ساده.)

6) چیدمان پیشنهادی (جمع‌وجور)

  • ردیف 1: 1) RPS 2) Avg Reserve 3) p95 HTTP 4) Error%
  • ردیف 2 (قیف): رزروها | بلیت صادرشده | SMS | Refund
  • ردیف 3 (سمفا): RPS Outbound | Avg Outbound | Max Outbound | Error% Webhook | p95 Webhook | Backlog
  • ردیف 4 (پرداخت/Refund): Mellat Token RPS | Avg | Max | Refund Avg | Invalid Refunds
  • ردیف 5 (API): RPS by URI | p50/p90/p99
  • ردیف 6 (DB/Queue): Hikari Active/Idle/Max/Pending | Acquire Avg | Redis Avg/Max | ThreadPool Load
  • ردیف 7 (JVM/System): Heap Used/Max | GC p95 | CPU | Load | Disk
  • ردیف 8 (Security): Auth Avg | FilterChains Count/Max

اگر دوست داری، اسم پنل‌ها رو دقیقاً این‌ها بگذار (خواناتر برای تیم عملیات):

  • «RPS کل سرویس»
  • «میانگین تأخیر رزرو»
  • «p95 تأخیر HTTP»
  • «نرخ خطا 5xx»
  • «رزروهای انجام‌شده (RPS)»
  • «میانگین تأخیر پاسخ رزرو»
  • «بلیت‌های صادرشده امروز»
  • «SMSهای ارسال‌شده امروز»
  • «Refund امروز»
  • «Refund نامعتبر امروز»
  • «تماس‌های خروجی به سمفا (RPS)»
  • «میانگین تأخیر تماس‌های سمفا»
  • «بیشینه تأخیر سمفا (5m)»
  • «نرخ خطای وب‌هوک سمفا»
  • «p95 وب‌هوک سمفا»
  • «Backlog همگام‌سازی»
  • «Mellat Token RPS / Avg / Max»
  • «Refund Avg (داخلی)»
  • «HTTP RPS بر اساس مسیر»
  • «HTTP p50/p90/p99»
  • «Hikari وضعیت/Acquire Avg»
  • «Redis Latency Avg/Max»
  • «ThreadPool Load»
  • «Heap / GC p95 / CPU / Load / Disk»
  • «Auth Avg / FilterChains»

اگه بخوام یک «چک‌لیست سریع» بدم:

  • مسیرهای سمفا و رزرو را با لیبل‌های قابل فیلتر (مثل uri, service, operation) استاندارد کن.
  • پنل‌های بالا را به‌ترتیب بساز.
  • آلارم‌ها را فعال کن.
  • متریک‌های تکمیلی دامنه‌محور (Lag/Consistency) را اضافه کن تا سناریو «آزاد شدن صندلی بعد از کنسلی در سیستم دیگر» را دقیق ببینی.

هرجا دوست داشتی، برای هر endpoint واقعی شما (/samfa/..., /reserve...) جایش را در کوئری‌ها با مقدار واقعی جایگزین کن و اگر لیبل‌هایت فرق می‌کند، فقط فیلترها را هم‌نام لیبل‌های خودت کن.

Share this Q&A