Rick Cheng
2 years ago
committed by
GitHub
8 changed files with 762 additions and 7 deletions
@ -0,0 +1,112 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.api.metrics; |
||||
|
||||
import lombok.experimental.UtilityClass; |
||||
import io.micrometer.core.instrument.Counter; |
||||
import io.micrometer.core.instrument.DistributionSummary; |
||||
import io.micrometer.core.instrument.Metrics; |
||||
|
||||
@UtilityClass |
||||
public class ApiServerMetrics { |
||||
|
||||
private final Counter apiRequestCounter = |
||||
Counter.builder("ds.api.request.count") |
||||
.description("Api request count") |
||||
.register(Metrics.globalRegistry); |
||||
|
||||
private final Counter apiResponse2xxCounter = |
||||
Counter.builder("ds.api.response.count") |
||||
.tag("code", "2xx") |
||||
.description("Api 2xx response count") |
||||
.register(Metrics.globalRegistry); |
||||
|
||||
private final Counter apiResponse3xxCounter = |
||||
Counter.builder("ds.api.response.count") |
||||
.tag("code", "3xx") |
||||
.description("Api 3xx response count") |
||||
.register(Metrics.globalRegistry); |
||||
|
||||
private final Counter apiResponse4xxCounter = |
||||
Counter.builder("ds.api.response.count") |
||||
.tag("code", "4xx") |
||||
.description("Api 4xx response count") |
||||
.register(Metrics.globalRegistry); |
||||
|
||||
private final Counter apiResponse5xxCounter = |
||||
Counter.builder("ds.api.response.count") |
||||
.tag("code", "5xx") |
||||
.description("Api 5xx response count") |
||||
.register(Metrics.globalRegistry); |
||||
|
||||
private final DistributionSummary apiResourceUploadSizeDistribution = |
||||
DistributionSummary.builder("ds.api.resource.upload.size") |
||||
.baseUnit("bytes") |
||||
.publishPercentiles(0.5, 0.75, 0.95, 0.99) |
||||
.publishPercentileHistogram() |
||||
.description("size of upload resource files on api") |
||||
.register(Metrics.globalRegistry); |
||||
|
||||
private final DistributionSummary apiResourceDownloadSizeDistribution = |
||||
DistributionSummary.builder("ds.api.resource.download.size") |
||||
.baseUnit("bytes") |
||||
.publishPercentiles(0.5, 0.75, 0.95, 0.99) |
||||
.publishPercentileHistogram() |
||||
.description("size of download resource files on api") |
||||
.register(Metrics.globalRegistry); |
||||
|
||||
private final DistributionSummary apiResponseTimeDistribution = |
||||
DistributionSummary.builder("ds.api.response.time") |
||||
.baseUnit("milliseconds") |
||||
.publishPercentiles(0.5, 0.75, 0.95, 0.99) |
||||
.publishPercentileHistogram() |
||||
.description("response time on api") |
||||
.register(Metrics.globalRegistry); |
||||
|
||||
public void incApiRequestCount() { |
||||
apiRequestCounter.increment(); |
||||
} |
||||
|
||||
public void incApiResponse2xxCount() { |
||||
apiResponse2xxCounter.increment(); |
||||
} |
||||
|
||||
public void incApiResponse3xxCount() { |
||||
apiResponse3xxCounter.increment(); |
||||
} |
||||
|
||||
public void incApiResponse4xxCount() { |
||||
apiResponse4xxCounter.increment(); |
||||
} |
||||
|
||||
public void incApiResponse5xxCount() { |
||||
apiResponse5xxCounter.increment(); |
||||
} |
||||
|
||||
public void recordApiResourceUploadSize(final long size) { |
||||
apiResourceUploadSizeDistribution.record(size); |
||||
} |
||||
|
||||
public void recordApiResourceDownloadSize(final long size) { |
||||
apiResourceDownloadSizeDistribution.record(size); |
||||
} |
||||
|
||||
public void recordApiResponseTime(final long milliseconds) { |
||||
apiResponseTimeDistribution.record(milliseconds); |
||||
} |
||||
} |
@ -0,0 +1,598 @@
|
||||
{ |
||||
"annotations": { |
||||
"list": [ |
||||
{ |
||||
"builtIn": 1, |
||||
"datasource": "-- Grafana --", |
||||
"enable": true, |
||||
"hide": true, |
||||
"iconColor": "rgba(0, 211, 255, 1)", |
||||
"name": "Annotations & Alerts", |
||||
"target": { |
||||
"limit": 100, |
||||
"matchAny": false, |
||||
"tags": [], |
||||
"type": "dashboard" |
||||
}, |
||||
"type": "dashboard" |
||||
} |
||||
] |
||||
}, |
||||
"editable": true, |
||||
"fiscalYearStartMonth": 0, |
||||
"graphTooltip": 0, |
||||
"id": 7, |
||||
"links": [], |
||||
"liveNow": false, |
||||
"panels": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "palette-classic" |
||||
}, |
||||
"custom": { |
||||
"axisLabel": "", |
||||
"axisPlacement": "auto", |
||||
"barAlignment": 0, |
||||
"drawStyle": "line", |
||||
"fillOpacity": 0, |
||||
"gradientMode": "none", |
||||
"hideFrom": { |
||||
"legend": false, |
||||
"tooltip": false, |
||||
"viz": false |
||||
}, |
||||
"lineInterpolation": "linear", |
||||
"lineWidth": 1, |
||||
"pointSize": 5, |
||||
"scaleDistribution": { |
||||
"type": "linear" |
||||
}, |
||||
"showPoints": "auto", |
||||
"spanNulls": false, |
||||
"stacking": { |
||||
"group": "A", |
||||
"mode": "none" |
||||
}, |
||||
"thresholdsStyle": { |
||||
"mode": "off" |
||||
} |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 0 |
||||
}, |
||||
"id": 2, |
||||
"options": { |
||||
"legend": { |
||||
"calcs": [], |
||||
"displayMode": "list", |
||||
"placement": "bottom" |
||||
}, |
||||
"tooltip": { |
||||
"mode": "single" |
||||
} |
||||
}, |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"exemplar": true, |
||||
"expr": "sum(increase(ds_api_request_count_total{}[1m]))", |
||||
"interval": "", |
||||
"legendFormat": "", |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Api Request Count/1m", |
||||
"type": "timeseries" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "palette-classic" |
||||
}, |
||||
"custom": { |
||||
"axisLabel": "", |
||||
"axisPlacement": "auto", |
||||
"barAlignment": 0, |
||||
"drawStyle": "line", |
||||
"fillOpacity": 0, |
||||
"gradientMode": "none", |
||||
"hideFrom": { |
||||
"legend": false, |
||||
"tooltip": false, |
||||
"viz": false |
||||
}, |
||||
"lineInterpolation": "linear", |
||||
"lineWidth": 1, |
||||
"pointSize": 5, |
||||
"scaleDistribution": { |
||||
"type": "linear" |
||||
}, |
||||
"showPoints": "auto", |
||||
"spanNulls": false, |
||||
"stacking": { |
||||
"group": "A", |
||||
"mode": "none" |
||||
}, |
||||
"thresholdsStyle": { |
||||
"mode": "off" |
||||
} |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 12, |
||||
"y": 0 |
||||
}, |
||||
"id": 8, |
||||
"options": { |
||||
"legend": { |
||||
"calcs": [], |
||||
"displayMode": "list", |
||||
"placement": "bottom" |
||||
}, |
||||
"tooltip": { |
||||
"mode": "single" |
||||
} |
||||
}, |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"exemplar": true, |
||||
"expr": "increase(ds_api_response_time_milliseconds{}[5m])", |
||||
"interval": "", |
||||
"legendFormat": "", |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Api Response Time/5m", |
||||
"type": "timeseries" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "palette-classic" |
||||
}, |
||||
"custom": { |
||||
"axisLabel": "", |
||||
"axisPlacement": "auto", |
||||
"barAlignment": 0, |
||||
"drawStyle": "line", |
||||
"fillOpacity": 0, |
||||
"gradientMode": "none", |
||||
"hideFrom": { |
||||
"legend": false, |
||||
"tooltip": false, |
||||
"viz": false |
||||
}, |
||||
"lineInterpolation": "linear", |
||||
"lineWidth": 1, |
||||
"pointSize": 5, |
||||
"scaleDistribution": { |
||||
"type": "linear" |
||||
}, |
||||
"showPoints": "auto", |
||||
"spanNulls": false, |
||||
"stacking": { |
||||
"group": "A", |
||||
"mode": "none" |
||||
}, |
||||
"thresholdsStyle": { |
||||
"mode": "off" |
||||
} |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 8 |
||||
}, |
||||
"id": 6, |
||||
"options": { |
||||
"legend": { |
||||
"calcs": [], |
||||
"displayMode": "list", |
||||
"placement": "bottom" |
||||
}, |
||||
"tooltip": { |
||||
"mode": "single" |
||||
} |
||||
}, |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"exemplar": true, |
||||
"expr": "sum(increase(ds_api_response_count_total{}[1m]))", |
||||
"interval": "", |
||||
"legendFormat": "", |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Api Response Count/1m", |
||||
"type": "timeseries" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "palette-classic" |
||||
}, |
||||
"custom": { |
||||
"axisLabel": "", |
||||
"axisPlacement": "auto", |
||||
"barAlignment": 0, |
||||
"drawStyle": "line", |
||||
"fillOpacity": 0, |
||||
"gradientMode": "none", |
||||
"hideFrom": { |
||||
"legend": false, |
||||
"tooltip": false, |
||||
"viz": false |
||||
}, |
||||
"lineInterpolation": "linear", |
||||
"lineWidth": 1, |
||||
"pointSize": 5, |
||||
"scaleDistribution": { |
||||
"type": "linear" |
||||
}, |
||||
"showPoints": "auto", |
||||
"spanNulls": false, |
||||
"stacking": { |
||||
"group": "A", |
||||
"mode": "none" |
||||
}, |
||||
"thresholdsStyle": { |
||||
"mode": "off" |
||||
} |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 12, |
||||
"y": 8 |
||||
}, |
||||
"id": 4, |
||||
"options": { |
||||
"legend": { |
||||
"calcs": [], |
||||
"displayMode": "list", |
||||
"placement": "bottom" |
||||
}, |
||||
"tooltip": { |
||||
"mode": "single" |
||||
} |
||||
}, |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"exemplar": true, |
||||
"expr": "sum(increase(ds_api_response_count_total{code=\"3xx\"}[1m]))", |
||||
"hide": false, |
||||
"interval": "", |
||||
"legendFormat": "", |
||||
"refId": "B" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"exemplar": true, |
||||
"expr": "sum(increase(ds_api_response_count_total{code=\"4xx\"}[1m]))", |
||||
"hide": false, |
||||
"interval": "", |
||||
"legendFormat": "", |
||||
"refId": "C" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"exemplar": true, |
||||
"expr": "sum(increase(ds_api_response_count_total{code=\"5xx\"}[1m]))", |
||||
"hide": false, |
||||
"interval": "", |
||||
"legendFormat": "", |
||||
"refId": "D" |
||||
} |
||||
], |
||||
"title": "Api Abnormal Response Count/1m", |
||||
"type": "timeseries" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "palette-classic" |
||||
}, |
||||
"custom": { |
||||
"axisLabel": "", |
||||
"axisPlacement": "auto", |
||||
"barAlignment": 0, |
||||
"drawStyle": "line", |
||||
"fillOpacity": 0, |
||||
"gradientMode": "none", |
||||
"hideFrom": { |
||||
"legend": false, |
||||
"tooltip": false, |
||||
"viz": false |
||||
}, |
||||
"lineInterpolation": "linear", |
||||
"lineWidth": 1, |
||||
"pointSize": 5, |
||||
"scaleDistribution": { |
||||
"type": "linear" |
||||
}, |
||||
"showPoints": "auto", |
||||
"spanNulls": false, |
||||
"stacking": { |
||||
"group": "A", |
||||
"mode": "none" |
||||
}, |
||||
"thresholdsStyle": { |
||||
"mode": "off" |
||||
} |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 16 |
||||
}, |
||||
"id": 10, |
||||
"options": { |
||||
"legend": { |
||||
"calcs": [], |
||||
"displayMode": "list", |
||||
"placement": "bottom" |
||||
}, |
||||
"tooltip": { |
||||
"mode": "single" |
||||
} |
||||
}, |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"exemplar": true, |
||||
"expr": "increase(ds_api_resource_upload_size_bytes{}[5m])", |
||||
"interval": "", |
||||
"legendFormat": "", |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Api Resource Upload Size/5m", |
||||
"type": "timeseries" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "palette-classic" |
||||
}, |
||||
"custom": { |
||||
"axisLabel": "", |
||||
"axisPlacement": "auto", |
||||
"barAlignment": 0, |
||||
"drawStyle": "line", |
||||
"fillOpacity": 0, |
||||
"gradientMode": "none", |
||||
"hideFrom": { |
||||
"legend": false, |
||||
"tooltip": false, |
||||
"viz": false |
||||
}, |
||||
"lineInterpolation": "linear", |
||||
"lineWidth": 1, |
||||
"pointSize": 5, |
||||
"scaleDistribution": { |
||||
"type": "linear" |
||||
}, |
||||
"showPoints": "auto", |
||||
"spanNulls": false, |
||||
"stacking": { |
||||
"group": "A", |
||||
"mode": "none" |
||||
}, |
||||
"thresholdsStyle": { |
||||
"mode": "off" |
||||
} |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 12, |
||||
"y": 16 |
||||
}, |
||||
"id": 12, |
||||
"options": { |
||||
"legend": { |
||||
"calcs": [], |
||||
"displayMode": "list", |
||||
"placement": "bottom" |
||||
}, |
||||
"tooltip": { |
||||
"mode": "single" |
||||
} |
||||
}, |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "prometheus", |
||||
"uid": "PBFA97CFB590B2093" |
||||
}, |
||||
"exemplar": true, |
||||
"expr": "increase(ds_api_resource_download_size_bytes{}[5m])", |
||||
"interval": "", |
||||
"legendFormat": "", |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Api Resource Download Size/5m", |
||||
"type": "timeseries" |
||||
} |
||||
], |
||||
"schemaVersion": 34, |
||||
"style": "dark", |
||||
"tags": [], |
||||
"templating": { |
||||
"list": [] |
||||
}, |
||||
"time": { |
||||
"from": "now-6h", |
||||
"to": "now" |
||||
}, |
||||
"timepicker": {}, |
||||
"timezone": "", |
||||
"title": "Api", |
||||
"uid": "437wjZQ4k", |
||||
"version": 6, |
||||
"weekStart": "" |
||||
} |
Loading…
Reference in new issue