diff --git a/contrib/mixin/dashboards/scheduled_tasks.libsonnet b/contrib/mixin/dashboards/scheduled_tasks.libsonnet index 0bc5dc91..2377f1ad 100644 --- a/contrib/mixin/dashboards/scheduled_tasks.libsonnet +++ b/contrib/mixin/dashboards/scheduled_tasks.libsonnet @@ -3,6 +3,7 @@ local metric(name, labels='') = 'windows_scheduled_task_' + name + '{job=~"$job" // Disabled tasks do not run, so their results and missed runs need no attention. local enabled(expr) = expr + ' and on (task) ' + metric('state', 'state!="disabled"') + ' == 1'; local requirement = ' Requires the scheduled_task collector, which is not enabled by default.'; +local missedRunsRequirement = ' Missed runs need --collector.scheduled_task.missed-runs, which is off by default.'; // Counts fall back to 0 only while the collector reports tasks, so a missing collector shows no data. local orZero = ' or (0 * count(' + metric('state') + '))'; local table(id, title, description, queries, columns, unit='short') = @@ -62,14 +63,15 @@ function(on) b.stat(191, 'Running', 'Tasks that are running now.' + requirement, 'sum(' + metric('state', 'state="running"') + ')' + orZero), b.stat(192, 'Disabled', 'Tasks that are disabled and do not run.' + requirement, 'sum(' + metric('state', 'state="disabled"') + ')' + orZero), b.stat(193, 'Unknown code', 'Enabled tasks whose last result code has no named status. This is usually a non-zero exit code of the task or a Task Scheduler error, so check the task history.' + requirement, 'count(' + enabled(metric('last_result_status', 'status="unknown"') + ' == 1') + ')' + orZero, steps=[{ color: 'green', value: null }, { color: 'orange', value: 1 }]), - b.stat(194, 'Missed runs', 'Enabled tasks that missed at least one scheduled run, for example because the host was off or asleep.' + requirement, 'count(' + enabled(metric('missed_runs') + ' > 0') + ')' + orZero), + // Falls back to 0 only while missed runs are collected, so the stat shows no data without the flag. + b.stat(194, 'Missed runs', 'Enabled tasks that missed at least one scheduled run, for example because the host was off or asleep.' + requirement + missedRunsRequirement, 'count(' + enabled(metric('missed_runs') + ' > 0') + ') or (0 * count(' + metric('missed_runs') + '))'), b.stat(195, 'Never run', 'Tasks that have not run since they were registered.' + requirement, 'sum(' + metric('last_result_status', 'status="has_not_run"') + ')' + orZero), table(196, 'Tasks with an unknown result code', 'Enabled tasks whose last result code has no named status, usually a non-zero exit code of the task or a Task Scheduler error.', [ { refId: 'A', expr: 'max by (task) (' + enabled(metric('last_result_status', 'status="unknown"') + ' == 1') + ')' }, ], [['task', 'Task']], unit='none'), - table(197, 'Tasks with missed runs', 'Enabled tasks that missed at least one scheduled run, with the number of missed runs reported by Task Scheduler.', [ + table(197, 'Tasks with missed runs', 'Enabled tasks that missed at least one scheduled run, with the number of missed runs reported by Task Scheduler.' + missedRunsRequirement, [ { refId: 'A', expr: 'max by (task) (' + enabled(metric('missed_runs') + ' > 0') + ')' }, ], [['task', 'Task'], ['Value', 'Missed runs']]) + b.panel.withOptions({ sortBy: [{ desc: true, displayName: 'Missed runs' }] }), @@ -100,7 +102,7 @@ function(on) ], }), - table(199, 'Tasks', 'All tasks with their state, last result and missed runs. Tasks that never ran report no missed runs.', [ + table(199, 'Tasks', 'All tasks with their state, last result and missed runs. Missed runs need --collector.scheduled_task.missed-runs, and tasks that never ran report none.', [ { refId: 'A', expr: 'max by (task, state, status) ((' + metric('state') + ' == 1) * on (task) group_left (status) (' + metric('last_result_status') + ' == 1))' }, { refId: 'B', expr: 'max by (task) (' + metric('missed_runs') + ')' }, ], [['task', 'Task'], ['state', 'State'], ['status', 'Last result'], ['Value #B', 'Missed runs']]) diff --git a/dashboard/windows-exporter-dashboard.json b/dashboard/windows-exporter-dashboard.json index d33ffae0..88f08910 100644 --- a/dashboard/windows-exporter-dashboard.json +++ b/dashboard/windows-exporter-dashboard.json @@ -9431,7 +9431,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_scheduled_task_missed_runs{job=~\"$job\", instance=\"$instance\"} > 0 and on (task) windows_scheduled_task_state{job=~\"$job\", instance=\"$instance\", state!=\"disabled\"} == 1) or (0 * count(windows_scheduled_task_state{job=~\"$job\", instance=\"$instance\"}))", + "expr": "count(windows_scheduled_task_missed_runs{job=~\"$job\", instance=\"$instance\"} > 0 and on (task) windows_scheduled_task_state{job=~\"$job\", instance=\"$instance\", state!=\"disabled\"} == 1) or (0 * count(windows_scheduled_task_missed_runs{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -9448,7 +9448,7 @@ "transformations": [] } }, - "description": "Enabled tasks that missed at least one scheduled run, for example because the host was off or asleep. Requires the scheduled_task collector, which is not enabled by default.", + "description": "Enabled tasks that missed at least one scheduled run, for example because the host was off or asleep. Requires the scheduled_task collector, which is not enabled by default. Missed runs need --collector.scheduled_task.missed-runs, which is off by default.", "id": 194, "links": [], "title": "Missed runs", @@ -9758,7 +9758,7 @@ ] } }, - "description": "Enabled tasks that missed at least one scheduled run, with the number of missed runs reported by Task Scheduler. Requires the scheduled_task collector, which is not enabled by default.", + "description": "Enabled tasks that missed at least one scheduled run, with the number of missed runs reported by Task Scheduler. Missed runs need --collector.scheduled_task.missed-runs, which is off by default. Requires the scheduled_task collector, which is not enabled by default.", "id": 197, "links": [], "title": "Tasks with missed runs", @@ -10029,7 +10029,7 @@ ] } }, - "description": "All tasks with their state, last result and missed runs. Tasks that never ran report no missed runs. Requires the scheduled_task collector, which is not enabled by default.", + "description": "All tasks with their state, last result and missed runs. Missed runs need --collector.scheduled_task.missed-runs, and tasks that never ran report none. Requires the scheduled_task collector, which is not enabled by default.", "id": 199, "links": [], "title": "Tasks", diff --git a/dashboard/windows-exporter-scheduled-tasks.json b/dashboard/windows-exporter-scheduled-tasks.json index 5e923c32..7e1d564a 100644 --- a/dashboard/windows-exporter-scheduled-tasks.json +++ b/dashboard/windows-exporter-scheduled-tasks.json @@ -421,7 +421,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_scheduled_task_missed_runs{job=~\"$job\", instance=\"$instance\"} > 0 and on (task) windows_scheduled_task_state{job=~\"$job\", instance=\"$instance\", state!=\"disabled\"} == 1) or (0 * count(windows_scheduled_task_state{job=~\"$job\", instance=\"$instance\"}))", + "expr": "count(windows_scheduled_task_missed_runs{job=~\"$job\", instance=\"$instance\"} > 0 and on (task) windows_scheduled_task_state{job=~\"$job\", instance=\"$instance\", state!=\"disabled\"} == 1) or (0 * count(windows_scheduled_task_missed_runs{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -438,7 +438,7 @@ "transformations": [] } }, - "description": "Enabled tasks that missed at least one scheduled run, for example because the host was off or asleep. Requires the scheduled_task collector, which is not enabled by default.", + "description": "Enabled tasks that missed at least one scheduled run, for example because the host was off or asleep. Requires the scheduled_task collector, which is not enabled by default. Missed runs need --collector.scheduled_task.missed-runs, which is off by default.", "id": 194, "links": [], "title": "Missed runs", @@ -748,7 +748,7 @@ ] } }, - "description": "Enabled tasks that missed at least one scheduled run, with the number of missed runs reported by Task Scheduler. Requires the scheduled_task collector, which is not enabled by default.", + "description": "Enabled tasks that missed at least one scheduled run, with the number of missed runs reported by Task Scheduler. Missed runs need --collector.scheduled_task.missed-runs, which is off by default. Requires the scheduled_task collector, which is not enabled by default.", "id": 197, "links": [], "title": "Tasks with missed runs", @@ -1019,7 +1019,7 @@ ] } }, - "description": "All tasks with their state, last result and missed runs. Tasks that never ran report no missed runs. Requires the scheduled_task collector, which is not enabled by default.", + "description": "All tasks with their state, last result and missed runs. Missed runs need --collector.scheduled_task.missed-runs, and tasks that never ran report none. Requires the scheduled_task collector, which is not enabled by default.", "id": 199, "links": [], "title": "Tasks",