|
|
Package metrics contains all metrics that needs to be exposed to Prometheus
and indirectly to Grafana. Currently, the following metrics are exposed:
consumed_messages - total number of messages consumed from selected broker
consuming_errors - total number of errors during consuming messages from selected broker
messageswithemptyruleexecution_result - total number of consumed messages not
processed as rule execution result is an empty report
successfulmessagesprocessing_time - time to process successfully message
failedmessagesprocessing_time - time to process message fail
lastcheckedtimestamplagminutes - shows how slow we get messages from clusters
produced_messages - total number of produced messages sent to Payload Tracker's Kafka topic
written_reports - total number of reports written into the storage (cache)
feedbackonrules - total number of left feedback
sqlqueriescounter - total number of SQL queries
sqlqueriesdurations - SQL queries durations
sqlrecommendationsupdates - number of insert and deletes in recommendations table
|
package metrics
import (
"github.com/RedHatInsights/insights-operator-utils/metrics"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
|
ConsumedMessages shows number of messages consumed from Kafka by aggregator
|
var ConsumedMessages = promauto . NewCounter ( prometheus . CounterOpts {
Name : "consumed_messages" ,
Help : "The total number of messages consumed from Kafka" ,
} )
|
ConsumingErrors shows the total number of errors during consuming messages from Kafka
|
var ConsumingErrors = promauto . NewCounter ( prometheus . CounterOpts {
Name : "consuming_errors" ,
Help : "The total number of errors during consuming messages from Kafka" ,
} )
|
SkippedEmptyReports shows the total number of consumed messages not processed as the rule execution resulted in an empty report
|
var SkippedEmptyReports = promauto . NewCounter ( prometheus . CounterOpts {
Name : "messages_with_empty_rule_execution_result" ,
Help : "The total number of consumed messages not processed as the rule execution resulted in an empty report" ,
} )
|
SuccessfulMessagesProcessingTime collects the time to process message successfully
|
var SuccessfulMessagesProcessingTime = promauto . NewHistogram ( prometheus . HistogramOpts {
Name : "successful_messages_processing_time" ,
Help : "Time to process successfully message" ,
} )
|
FailedMessagesProcessingTime collects the time of processing message when it failed
|
var FailedMessagesProcessingTime = promauto . NewHistogram ( prometheus . HistogramOpts {
Name : "failed_messages_processing_time" ,
Help : "Time to process message fail" ,
} )
|
LastCheckedTimestampLagMinutes shows how slow we get messages from clusters
|
var LastCheckedTimestampLagMinutes = promauto . NewHistogram ( prometheus . HistogramOpts {
Name : "last_checked_timestamp_lag_minutes" ,
Help : "Shows how slow we get messages from clusters" ,
} )
|
ProducedMessages shows number of messages produced by producer package
probably it will be used only in tests
|
var ProducedMessages = promauto . NewCounter ( prometheus . CounterOpts {
Name : "produced_messages" ,
Help : "The total number of produced messages sent to Payload Tracker's Kafka topic" ,
} )
|
WrittenReports shows number of reports written into the database
|
var WrittenReports = promauto . NewCounter ( prometheus . CounterOpts {
Name : "written_reports" ,
Help : "The total number of reports written to the storage" ,
} )
|
FeedbackOnRules shows how many times users left feedback on rules
|
var FeedbackOnRules = promauto . NewCounter ( prometheus . CounterOpts {
Name : "feedback_on_rules" ,
Help : "The total number of left feedback" ,
} )
|
RatingOnRules shows how many times users sends a rating on rules
|
var RatingOnRules = promauto . NewCounter ( prometheus . CounterOpts {
Name : "rating_on_rules" ,
Help : "The total number of left rating" ,
} )
|
SQLQueriesCounter shows number of sql queries
|
var SQLQueriesCounter = promauto . NewCounter ( prometheus . CounterOpts {
Name : "sql_queries_counter" ,
Help : "Number of SQL queries" ,
} )
|
SQLQueriesDurations shows durations for sql queries (without parameters).
|
var SQLQueriesDurations = promauto . NewHistogramVec ( prometheus . HistogramOpts {
Name : "sql_queries_durations" ,
Help : "SQL queries durations" ,
} , [ ] string { "query" } )
var SQLRecommendationsDeletes = promauto . NewHistogramVec ( prometheus . HistogramOpts {
Name : "sql_recommendations_deletes" ,
Help : "Number of rows removed from the SQL recommendation table when new report is processed" ,
} , [ ] string { "cluster" } )
|
SQLRecommendationsDeletes shows deleted entries in recommendations table.
|
var SQLRecommendationsInserts = promauto . NewHistogramVec ( prometheus . HistogramOpts {
Name : "sql_recommendations_inserts" ,
Help : "Number of rows added to the SQL recommendation table when new report is processed" ,
} , [ ] string { "cluster" } )
* /
|
SQLRecommendationsInserts shows inserted entries in recommendations table.
|
func AddMetricsWithNamespace ( namespace string ) {
metrics . AddAPIMetricsWithNamespace ( namespace )
prometheus . Unregister ( ConsumedMessages )
prometheus . Unregister ( ConsumingErrors )
prometheus . Unregister ( SkippedEmptyReports )
prometheus . Unregister ( SuccessfulMessagesProcessingTime )
prometheus . Unregister ( FailedMessagesProcessingTime )
prometheus . Unregister ( LastCheckedTimestampLagMinutes )
prometheus . Unregister ( ProducedMessages )
prometheus . Unregister ( WrittenReports )
prometheus . Unregister ( FeedbackOnRules )
prometheus . Unregister ( SQLQueriesCounter )
prometheus . Unregister ( SQLQueriesDurations )
|
AddMetricsWithNamespace register the desired metrics using a given namespace
|
ConsumedMessages = promauto . NewCounter ( prometheus . CounterOpts {
Namespace : namespace ,
Name : "consumed_messages" ,
Help : "The total number of messages consumed from Kafka" ,
} )
ConsumingErrors = promauto . NewCounter ( prometheus . CounterOpts {
Namespace : namespace ,
Name : "consuming_errors" ,
Help : "The total number of errors during consuming messages from Kafka" ,
} )
SkippedEmptyReports = promauto . NewCounter ( prometheus . CounterOpts {
Namespace : namespace ,
Name : "messages_with_empty_rule_execution_result" ,
Help : "The total number of consumed messages not processed as the rule execution resulted in an empty report" ,
} )
SuccessfulMessagesProcessingTime = promauto . NewHistogram ( prometheus . HistogramOpts {
Namespace : namespace ,
Name : "successful_messages_processing_time" ,
Help : "Time to process successfully message" ,
} )
FailedMessagesProcessingTime = promauto . NewHistogram ( prometheus . HistogramOpts {
Namespace : namespace ,
Name : "failed_messages_processing_time" ,
Help : "Time to process message fail" ,
} )
LastCheckedTimestampLagMinutes = promauto . NewHistogram ( prometheus . HistogramOpts {
Namespace : namespace ,
Name : "last_checked_timestamp_lag_minutes" ,
Help : "Shows how slow we get messages from clusters" ,
} )
ProducedMessages = promauto . NewCounter ( prometheus . CounterOpts {
Namespace : namespace ,
Name : "produced_messages" ,
Help : "The total number of produced messages sent to Payload Tracker's Kafka topic" ,
} )
WrittenReports = promauto . NewCounter ( prometheus . CounterOpts {
Namespace : namespace ,
Name : "written_reports" ,
Help : "The total number of reports written to the storage" ,
} )
FeedbackOnRules = promauto . NewCounter ( prometheus . CounterOpts {
Namespace : namespace ,
Name : "feedback_on_rules" ,
Help : "The total number of left feedback" ,
} )
SQLQueriesCounter = promauto . NewCounter ( prometheus . CounterOpts {
Namespace : namespace ,
Name : "sql_queries_counter" ,
Help : "Number of SQL queries" ,
} )
SQLQueriesDurations = promauto . NewHistogramVec ( prometheus . HistogramOpts {
Namespace : namespace ,
Name : "sql_queries_durations" ,
Help : "SQL queries durations" ,
} , [ ] string { "query" } )
}
|
prometheus.Unregister(SQLRecommendationsDeletes)
prometheus.Unregister(SQLRecommendationsInserts)
|
ConsumedMessages = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "consumed_messages",
Help: "The total number of messages consumed from Kafka",
})
ConsumingErrors = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "consuming_errors",
Help: "The total number of errors during consuming messages from Kafka",
})
SkippedEmptyReports = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "messages_with_empty_rule_execution_result",
Help: "The total number of consumed messages not processed as the rule execution resulted in an empty report",
})
SuccessfulMessagesProcessingTime = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Name: "successful_messages_processing_time",
Help: "Time to process successfully message",
})
FailedMessagesProcessingTime = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Name: "failed_messages_processing_time",
Help: "Time to process message fail",
})
LastCheckedTimestampLagMinutes = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Name: "last_checked_timestamp_lag_minutes",
Help: "Shows how slow we get messages from clusters",
})
ProducedMessages = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "produced_messages",
Help: "The total number of produced messages sent to Payload Tracker's Kafka topic",
})
WrittenReports = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "written_reports",
Help: "The total number of reports written to the storage",
})
FeedbackOnRules = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "feedback_on_rules",
Help: "The total number of left feedback",
})
SQLQueriesCounter = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "sql_queries_counter",
Help: "Number of SQL queries",
})
SQLQueriesDurations = promauto.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Name: "sql_queries_durations",
Help: "SQL queries durations",
}, []string{"query"})
/*
SQLRecommendationsDeletes = promauto.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Name: "sql_recommendations_deletes",
Help: "Number of rows removed from the SQL recommendation table when new report is processed",
}, []string{"cluster"})
SQLRecommendationsInserts = promauto.NewHistogramVec(prometheus.HistogramOpts{
Namespace: namespace,
Name: "sql_recommendations_inserts",
Help: "Number of rows added to the SQL recommendation table when new report is processed",
}, []string{"cluster"})
*/
}
|