|
| 1 | +local common_utils = import 'common.libsonnet'; |
| 2 | +local grafana = import 'grafonnet/grafana.libsonnet'; |
| 3 | + |
| 4 | +local influxdb = grafana.influxdb; |
| 5 | +local prometheus = grafana.prometheus; |
| 6 | + |
| 7 | +{ |
| 8 | + row:: common_utils.row('expirationd module statistics'), |
| 9 | + |
| 10 | + local target( |
| 11 | + datasource, |
| 12 | + metric_name, |
| 13 | + job=null, |
| 14 | + policy=null, |
| 15 | + measurement=null, |
| 16 | + ) = |
| 17 | + if datasource == '${DS_PROMETHEUS}' then |
| 18 | + prometheus.target( |
| 19 | + expr=std.format('%s{job=~"%s"}', [metric_name, job]), |
| 20 | + legendFormat='{{name}} — {{alias}}', |
| 21 | + ) |
| 22 | + else if datasource == '${DS_INFLUXDB}' then |
| 23 | + influxdb.target( |
| 24 | + policy=policy, |
| 25 | + measurement=measurement, |
| 26 | + group_tags=[ |
| 27 | + 'label_pairs_alias', |
| 28 | + 'label_pairs_name', |
| 29 | + ], |
| 30 | + alias='$tag_label_pairs_name — $tag_label_pairs_alias', |
| 31 | + ).where('metric_name', '=', metric_name) |
| 32 | + .selectField('value').addConverter('mean'), |
| 33 | + |
| 34 | + local rps_target( |
| 35 | + datasource, |
| 36 | + metric_name, |
| 37 | + job=null, |
| 38 | + rate_time_range=null, |
| 39 | + policy=null, |
| 40 | + measurement=null, |
| 41 | + ) = |
| 42 | + if datasource == '${DS_PROMETHEUS}' then |
| 43 | + prometheus.target( |
| 44 | + expr=std.format('rate(%s{job=~"%s"}[%s])', |
| 45 | + [metric_name, job, rate_time_range]), |
| 46 | + legendFormat='{{name}} — {{alias}}', |
| 47 | + ) |
| 48 | + else if datasource == '${DS_INFLUXDB}' then |
| 49 | + influxdb.target( |
| 50 | + policy=policy, |
| 51 | + measurement=measurement, |
| 52 | + group_tags=[ |
| 53 | + 'label_pairs_alias', |
| 54 | + 'label_pairs_name', |
| 55 | + ], |
| 56 | + alias='$tag_label_pairs_name — $tag_label_pairs_alias', |
| 57 | + ).where('metric_name', '=', metric_name) |
| 58 | + .selectField('value').addConverter('mean').addConverter('non_negative_derivative', ['1s']), |
| 59 | + |
| 60 | + tuples_checked( |
| 61 | + title='Tuples checked', |
| 62 | + description=common_utils.rate_warning(||| |
| 63 | + A number of task tuples checked for expiration (expired + skipped). |
| 64 | + Graph shows mean tuples per second. |
| 65 | + |||), |
| 66 | + datasource=null, |
| 67 | + policy=null, |
| 68 | + measurement=null, |
| 69 | + job=null, |
| 70 | + rate_time_range=null, |
| 71 | + ):: common_utils.default_graph( |
| 72 | + title=title, |
| 73 | + description=description, |
| 74 | + datasource=datasource, |
| 75 | + labelY1='tuples per second', |
| 76 | + panel_width=12, |
| 77 | + ).addTarget(rps_target( |
| 78 | + datasource, |
| 79 | + 'expirationd_checked_count', |
| 80 | + job, |
| 81 | + rate_time_range, |
| 82 | + policy, |
| 83 | + measurement, |
| 84 | + )), |
| 85 | + |
| 86 | + tuples_expired( |
| 87 | + title='Tuples expired', |
| 88 | + description=common_utils.rate_warning(||| |
| 89 | + A number of task expired tuples. |
| 90 | + Graph shows mean tuples per second. |
| 91 | + |||, datasource), |
| 92 | + datasource=null, |
| 93 | + policy=null, |
| 94 | + measurement=null, |
| 95 | + job=null, |
| 96 | + rate_time_range=null, |
| 97 | + ):: common_utils.default_graph( |
| 98 | + title=title, |
| 99 | + description=description, |
| 100 | + datasource=datasource, |
| 101 | + labelY1='tuples per second', |
| 102 | + panel_width=12, |
| 103 | + ).addTarget(rps_target( |
| 104 | + datasource, |
| 105 | + 'expirationd_expired_count', |
| 106 | + job, |
| 107 | + rate_time_range, |
| 108 | + policy, |
| 109 | + measurement, |
| 110 | + )), |
| 111 | + |
| 112 | + restarts( |
| 113 | + title='Restart count', |
| 114 | + description=||| |
| 115 | + A number of task restarts since start. |
| 116 | + From the start is equal to 1. |
| 117 | + |||, |
| 118 | + datasource=null, |
| 119 | + policy=null, |
| 120 | + measurement=null, |
| 121 | + job=null, |
| 122 | + ):: common_utils.default_graph( |
| 123 | + title=title, |
| 124 | + description=description, |
| 125 | + datasource=datasource, |
| 126 | + decimals=0, |
| 127 | + panel_width=12, |
| 128 | + ).addTarget(target( |
| 129 | + datasource, |
| 130 | + 'expirationd_restarts', |
| 131 | + job, |
| 132 | + policy, |
| 133 | + measurement, |
| 134 | + )), |
| 135 | + |
| 136 | + operation_time( |
| 137 | + title='Operation time', |
| 138 | + description=||| |
| 139 | + A task's operation time. |
| 140 | + |||, |
| 141 | + datasource=null, |
| 142 | + policy=null, |
| 143 | + measurement=null, |
| 144 | + job=null, |
| 145 | + ):: common_utils.default_graph( |
| 146 | + title=title, |
| 147 | + description=description, |
| 148 | + datasource=datasource, |
| 149 | + format='s', |
| 150 | + panel_width=12, |
| 151 | + ).addTarget(target( |
| 152 | + datasource, |
| 153 | + 'expirationd_working_time', |
| 154 | + job, |
| 155 | + policy, |
| 156 | + measurement, |
| 157 | + )), |
| 158 | +} |
0 commit comments