-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new pod pending counter metric
The workflow controller is a kubernetes controller creating pods. Sometimes those pods do not start, and will remain in pending. This metric counts the number of pods that may have been observed as pending, by namespace and truncated reason. The reason is the first part of the kubernetes pod pending `Reason` up to the first `:` if present. It ignores all pods in the `PodInitializing` state as this I consider unremarkable and temporary. This is intended for users to create alerts on particular `reasons` or if this metric is climbing unusually rapidly. Note to reviewers: this is part of a stack of reviews for metrics changes. Please don't merge until the rest of the stack is also ready. Signed-off-by: Alan Clucas <[email protected]>
- Loading branch information
Showing
8 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: workflow-pending-metrics- | ||
spec: | ||
entrypoint: main | ||
nodeSelector: | ||
arch: nonexistent | ||
templates: | ||
- name: main | ||
steps: | ||
- - name: runTest | ||
template: run-test | ||
- name: run-test | ||
container: | ||
name: runner | ||
image: 'argoproj/argosay:v2' | ||
args: | ||
- exit 1 | ||
command: | ||
- sh | ||
- -c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package metrics | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
) | ||
|
||
const ( | ||
namePodPending = `pod_pending_count` | ||
) | ||
|
||
func addPodPendingCounter(_ context.Context, m *Metrics) error { | ||
return m.createInstrument(int64Counter, | ||
namePodPending, | ||
"Total number of pods that started pending by reason", | ||
"{pod}", | ||
withAsBuiltIn(), | ||
) | ||
} | ||
|
||
func (m *Metrics) ChangePodPending(ctx context.Context, reason, namespace string) { | ||
// Reason strings have a lot of stuff that would result in insane cardinatlity | ||
// so we just take everything from before the first : | ||
splitReason := strings.Split(reason, `:`) | ||
switch splitReason[0] { | ||
case "PodInitializing": | ||
// Drop these, they are uninteresting and usually short | ||
// the pod_phase metric can cope with this being visible | ||
return | ||
default: | ||
m.addInt(ctx, namePodPending, 1, instAttribs{ | ||
{name: labelPodPendingReason, value: splitReason[0]}, | ||
{name: labelPodNamespace, value: namespace}, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters