3.3. Camel K Operator のアラート
OpenShift モニタリングスタックからの AlertManager インスタンスが Camel K Operator によって公開されるメトリクスに基づいてアラートをトリガーできるように、PrometheusRule
リソースを作成することができます。
例
以下のように、公開されるメトリクスに基づいて、アラートルールで PrometheusRule
リソースを作成できます。
apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: camel-k-operator spec: groups: - name: camel-k-operator rules: - alert: CamelKReconciliationDuration expr: | ( 1 - sum(rate(camel_k_reconciliation_duration_seconds_bucket{le="0.5"}[5m])) by (job) / sum(rate(camel_k_reconciliation_duration_seconds_count[5m])) by (job) ) * 100 > 10 for: 1m labels: severity: warning annotations: message: | {{ printf "%0.0f" $value }}% of the reconciliation requests for {{ $labels.job }} have their duration above 0.5s. - alert: CamelKReconciliationFailure expr: | sum(rate(camel_k_reconciliation_duration_seconds_count{result="Errored"}[5m])) by (job) / sum(rate(camel_k_reconciliation_duration_seconds_count[5m])) by (job) * 100 > 1 for: 10m labels: severity: warning annotations: message: | {{ printf "%0.0f" $value }}% of the reconciliation requests for {{ $labels.job }} have failed. - alert: CamelKSuccessBuildDuration2m expr: | ( 1 - sum(rate(camel_k_build_duration_seconds_bucket{le="120",result="Succeeded"}[5m])) by (job) / sum(rate(camel_k_build_duration_seconds_count{result="Succeeded"}[5m])) by (job) ) * 100 > 10 for: 1m labels: severity: warning annotations: message: | {{ printf "%0.0f" $value }}% of the successful builds for {{ $labels.job }} have their duration above 2m. - alert: CamelKSuccessBuildDuration5m expr: | ( 1 - sum(rate(camel_k_build_duration_seconds_bucket{le="300",result="Succeeded"}[5m])) by (job) / sum(rate(camel_k_build_duration_seconds_count{result="Succeeded"}[5m])) by (job) ) * 100 > 1 for: 1m labels: severity: critical annotations: message: | {{ printf "%0.0f" $value }}% of the successful builds for {{ $labels.job }} have their duration above 5m. - alert: CamelKBuildFailure expr: | sum(rate(camel_k_build_duration_seconds_count{result="Failed"}[5m])) by (job) / sum(rate(camel_k_build_duration_seconds_count[5m])) by (job) * 100 > 1 for: 10m labels: severity: warning annotations: message: | {{ printf "%0.0f" $value }}% of the builds for {{ $labels.job }} have failed. - alert: CamelKBuildError expr: | sum(rate(camel_k_build_duration_seconds_count{result="Error"}[5m])) by (job) / sum(rate(camel_k_build_duration_seconds_count[5m])) by (job) * 100 > 1 for: 10m labels: severity: critical annotations: message: | {{ printf "%0.0f" $value }}% of the builds for {{ $labels.job }} have errored. - alert: CamelKBuildQueueDuration1m expr: | ( 1 - sum(rate(camel_k_build_queue_duration_seconds_bucket{le="60"}[5m])) by (job) / sum(rate(camel_k_build_queue_duration_seconds_count[5m])) by (job) ) * 100 > 1 for: 1m labels: severity: warning annotations: message: | {{ printf "%0.0f" $value }}% of the builds for {{ $labels.job }} have been queued for more than 1m. - alert: CamelKBuildQueueDuration5m expr: | ( 1 - sum(rate(camel_k_build_queue_duration_seconds_bucket{le="300"}[5m])) by (job) / sum(rate(camel_k_build_queue_duration_seconds_count[5m])) by (job) ) * 100 > 1 for: 1m labels: severity: critical annotations: message: | {{ printf "%0.0f" $value }}% of the builds for {{ $labels.job }} have been queued for more than 5m.
Camel K Operator のアラート
以下の表は、PrometheusRule
リソースで定義されるアラートルールを示しています。
名前 | 重大度 | 説明 |
---|---|---|
| warning | 全体の 10% を超える調整要求で、最低でも 1 分の間に期間が 0.5 秒を超える。 |
| warning | 全体の 1% を超える調整要求が、最低でも 10 分間失敗している。 |
| warning | 全体の 10% を超える正常なビルドで、最低でも 1 分の間に期間が 2 分を超える。 |
| critical | 全体の 1% を超える正常なビルドで、最低でも 1 分の間に期間が 5 分を超える。 |
| critical | 全体の 1% を超えるビルドで、最低でも 10 分間エラーが発生している。 |
| warning | 全体の 1% を超えるビルドが、最低でも 1 分間 1 分を超えてキューに入れられている。 |
| critical | 全体の 1% を超えるビルドが、最低でも 1 分間 5 分を超えてキューに入れられている。 |
アラートについての詳細は、OpenShift のドキュメントの「Creating alerting rules」を参照してください。