|
| 1 | +local grafana = import 'grafonnet/grafana.libsonnet'; |
| 2 | + |
| 3 | +local graph = grafana.graphPanel; |
| 4 | +local influxdb = grafana.influxdb; |
| 5 | + |
| 6 | +{ |
| 7 | + local rps_graph( |
| 8 | + title, |
| 9 | + description, |
| 10 | + datasource, |
| 11 | + measurement, |
| 12 | + metric_name, |
| 13 | + status_regex, |
| 14 | + ) = graph.new( |
| 15 | + title=title, |
| 16 | + description=description, |
| 17 | + datasource=datasource, |
| 18 | + |
| 19 | + format='none', |
| 20 | + labelY1='requests per second', |
| 21 | + fill=0, |
| 22 | + decimals=2, |
| 23 | + decimalsY1=0, |
| 24 | + sort='decreasing', |
| 25 | + legend_alignAsTable=true, |
| 26 | + legend_avg=true, |
| 27 | + legend_current=true, |
| 28 | + legend_max=true, |
| 29 | + legend_values=true, |
| 30 | + legend_sort='current', |
| 31 | + legend_sortDesc=true, |
| 32 | + ).addTarget( |
| 33 | + influxdb.target( |
| 34 | + measurement=measurement, |
| 35 | + group_tags=['label_pairs_alias', 'label_pairs_path', 'label_pairs_method', 'label_pairs_status'], |
| 36 | + alias='$tag_label_pairs_alias — $tag_label_pairs_method $tag_label_pairs_path (code $tag_label_pairs_status)', |
| 37 | + ).where('metric_name', '=', metric_name).where('label_pairs_status', '=~', status_regex) |
| 38 | + .selectField('value').addConverter('mean').addConverter('non_negative_derivative', ['1s']) |
| 39 | + ), |
| 40 | + |
| 41 | + rps_success( |
| 42 | + title='Success requests (code 2xx)', |
| 43 | + description=||| |
| 44 | + Requests, processed with success (code 2xx) on Tarantool's side. |
| 45 | + Graph shows mean count per second. |
| 46 | + |||, |
| 47 | + |
| 48 | + datasource=null, |
| 49 | + measurement=null, |
| 50 | + metric_name='http_server_request_latency_count', |
| 51 | + ):: rps_graph( |
| 52 | + title=title, |
| 53 | + description=description, |
| 54 | + datasource=datasource, |
| 55 | + measurement=measurement, |
| 56 | + metric_name=metric_name, |
| 57 | + status_regex='/^2\\d{2}$/', |
| 58 | + ), |
| 59 | + |
| 60 | + rps_error_4xx( |
| 61 | + title='Error requests (code 4xx)', |
| 62 | + description=||| |
| 63 | + Requests, processed with 4xx error on Tarantool's side. |
| 64 | + Graph shows mean count per second. |
| 65 | + |||, |
| 66 | + |
| 67 | + datasource=null, |
| 68 | + measurement=null, |
| 69 | + metric_name='http_server_request_latency_count', |
| 70 | + ):: rps_graph( |
| 71 | + title=title, |
| 72 | + description=description, |
| 73 | + datasource=datasource, |
| 74 | + measurement=measurement, |
| 75 | + metric_name=metric_name, |
| 76 | + status_regex='/^4\\d{2}$/', |
| 77 | + ), |
| 78 | + |
| 79 | + rps_error_5xx( |
| 80 | + title='Error requests (code 5xx)', |
| 81 | + description=||| |
| 82 | + Requests, processed with 5xx error on Tarantool's side. |
| 83 | + Graph shows mean count per second. |
| 84 | + |||, |
| 85 | + |
| 86 | + datasource=null, |
| 87 | + measurement=null, |
| 88 | + metric_name='http_server_request_latency_count', |
| 89 | + ):: rps_graph( |
| 90 | + title=title, |
| 91 | + description=description, |
| 92 | + datasource=datasource, |
| 93 | + measurement=measurement, |
| 94 | + metric_name=metric_name, |
| 95 | + status_regex='/^5\\d{2}$/', |
| 96 | + ), |
| 97 | + |
| 98 | + local latency_graph( |
| 99 | + title, |
| 100 | + description, |
| 101 | + datasource, |
| 102 | + measurement, |
| 103 | + metric_name, |
| 104 | + status_regex, |
| 105 | + ) = graph.new( |
| 106 | + title=title, |
| 107 | + description=description, |
| 108 | + datasource=datasource, |
| 109 | + |
| 110 | + format='s', |
| 111 | + labelY1='average', |
| 112 | + fill=0, |
| 113 | + decimals=3, |
| 114 | + decimalsY1=2, |
| 115 | + sort='decreasing', |
| 116 | + legend_alignAsTable=true, |
| 117 | + legend_avg=true, |
| 118 | + legend_current=true, |
| 119 | + legend_max=true, |
| 120 | + legend_values=true, |
| 121 | + legend_sort='current', |
| 122 | + legend_sortDesc=true, |
| 123 | + ).addTarget( |
| 124 | + influxdb.target( |
| 125 | + measurement=measurement, |
| 126 | + group_tags=['label_pairs_alias', 'label_pairs_path', 'label_pairs_method', 'label_pairs_status'], |
| 127 | + alias='$tag_label_pairs_alias — $tag_label_pairs_method $tag_label_pairs_path (code $tag_label_pairs_status)', |
| 128 | + ).where('metric_name', '=', metric_name).where('label_pairs_status', '=~', status_regex) |
| 129 | + .selectField('value').addConverter('mean') |
| 130 | + ), |
| 131 | + |
| 132 | + latency_success( |
| 133 | + title='Success requests latency (code 2xx)', |
| 134 | + description=||| |
| 135 | + Latency of requests, processed with success (code 2xx) on Tarantool's side. |
| 136 | + |||, |
| 137 | + |
| 138 | + datasource=null, |
| 139 | + measurement=null, |
| 140 | + metric_name='http_server_request_latency_avg', |
| 141 | + ):: latency_graph( |
| 142 | + title=title, |
| 143 | + description=description, |
| 144 | + datasource=datasource, |
| 145 | + measurement=measurement, |
| 146 | + metric_name=metric_name, |
| 147 | + status_regex='/^2\\d{2}$/', |
| 148 | + ), |
| 149 | + |
| 150 | + latency_error_4xx( |
| 151 | + title='Error requests latency (code 4xx)', |
| 152 | + description=||| |
| 153 | + Latency of requests, processed with 4xx error on Tarantool's side. |
| 154 | + |||, |
| 155 | + |
| 156 | + datasource=null, |
| 157 | + measurement=null, |
| 158 | + metric_name='http_server_request_latency_avg', |
| 159 | + ):: latency_graph( |
| 160 | + title=title, |
| 161 | + description=description, |
| 162 | + datasource=datasource, |
| 163 | + measurement=measurement, |
| 164 | + metric_name=metric_name, |
| 165 | + status_regex='/^4\\d{2}$/', |
| 166 | + ), |
| 167 | + |
| 168 | + latency_error_5xx( |
| 169 | + title='Error requests latency (code 5xx)', |
| 170 | + description=||| |
| 171 | + Latency of requests, processed with 5xx error on Tarantool's side. |
| 172 | + |||, |
| 173 | + |
| 174 | + datasource=null, |
| 175 | + measurement=null, |
| 176 | + metric_name='http_server_request_latency_avg', |
| 177 | + ):: latency_graph( |
| 178 | + title=title, |
| 179 | + description=description, |
| 180 | + datasource=datasource, |
| 181 | + measurement=measurement, |
| 182 | + metric_name=metric_name, |
| 183 | + status_regex='/^5\\d{2}$/', |
| 184 | + ), |
| 185 | +} |
0 commit comments