タイムラインの遅延等の計測を改善
docker-ci / docker (push) Successful in 57s Details

This commit is contained in:
usbharu 2025-04-18 12:32:40 +09:00
parent cf3d15fa77
commit dcdbfc4f58
Signed by: usbharu
GPG Key ID: 8CB1087135660B8D
8 changed files with 1133 additions and 21 deletions

25
.idea/jsonSchemas.xml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JsonSchemaMappingsProjectConfiguration">
<state>
<map>
<entry key="prometheus.rules.json">
<value>
<SchemaInfo>
<option name="name" value="prometheus.rules.json" />
<option name="relativePathToSchema" value="https://json.schemastore.org/prometheus.rules.json" />
<option name="applicationDefined" value="true" />
<option name="patterns">
<list>
<Item>
<option name="path" value="rules.yaml" />
</Item>
</list>
</option>
</SchemaInfo>
</value>
</entry>
</map>
</state>
</component>
</project>

View File

@ -1,10 +1,10 @@
# ステージ1 # ステージ1
FROM golang:1.23.5-alpine3.21 AS go FROM golang:1.23.5-alpine3.21 AS go
WORKDIR /app WORKDIR /app
COPY go.mod go.sum main.go collector.go ./ COPY go.mod go.sum ./
RUN go mod download \ RUN go mod download
&& go build -o main . COPY main.go collector.go ./
RUN go build -o main .
# ステージ2 # ステージ2
FROM alpine:3.21 FROM alpine:3.21
WORKDIR /app WORKDIR /app

View File

@ -15,7 +15,7 @@ func collectJobqueue() {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
stats, err := client.Admin().Queue().Stats() stats, err := client.Admin().Queue().Stats()
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "jobqueue").Warning(err)
continue continue
} }
misskeyJobQueueJobsCount.WithLabelValues("deliver", "waiting").Set(float64(stats.Deliver.Waiting)) misskeyJobQueueJobsCount.WithLabelValues("deliver", "waiting").Set(float64(stats.Deliver.Waiting))
@ -52,17 +52,20 @@ func collectPing() {
start := time.Now() start := time.Now()
resp, err := http.Post("https://"+endpoint+"/api/ping", "application/json", buf) resp, err := http.Post("https://"+endpoint+"/api/ping", "application/json", buf)
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "ping").Warning(err)
continue continue
} }
err = resp.Body.Close() err = resp.Body.Close()
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "ping").Warning(err)
continue continue
} }
misskeyPingResponseCode.Set(float64(resp.StatusCode)) misskeyPingResponseCode.Set(float64(resp.StatusCode))
misskeyPingResponseTime.Observe(float64(time.Since(start).Milliseconds()) / 1000) t := float64(time.Since(start).Milliseconds()) / 1000
misskeyPingResponseTimeRaw.Set(float64(time.Since(start).Milliseconds()) / 1000) misskeyPingResponseTime.Observe(t)
misskeyPingResponseTimeRaw.Set(t)
misskeyApiResponseTime.WithLabelValues("ping", "").Observe(t)
misskeyApiResponseTimeRaw.WithLabelValues("ping", "").Set(t)
} }
} }
@ -89,11 +92,11 @@ func collectOnlineUsers() {
time.Sleep(1 * time.Minute) time.Sleep(1 * time.Minute)
response, err := http.Get("https://" + endpoint + "/api/get-online-users-count") response, err := http.Get("https://" + endpoint + "/api/get-online-users-count")
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "online-users").Warning(err)
continue continue
} }
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "online-users").Warning(err)
continue continue
} }
var onlineUsers OnlineUsers var onlineUsers OnlineUsers
@ -101,13 +104,13 @@ func collectOnlineUsers() {
all, err := io.ReadAll(response.Body) all, err := io.ReadAll(response.Body)
err = response.Body.Close() err = response.Body.Close()
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "online-users").Warning(err)
continue continue
} }
err = json.Unmarshal(all, &onlineUsers) err = json.Unmarshal(all, &onlineUsers)
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "online-users").Warning(err)
} }
misskeyOnlineUsers.Set(float64(onlineUsers.Count)) misskeyOnlineUsers.Set(float64(onlineUsers.Count))
} }
@ -120,11 +123,14 @@ func collectTimeline() {
start := time.Now() start := time.Now()
global, err := client.Notes().Timeline().Global(timeline.GlobalRequest{Limit: 10}) global, err := client.Notes().Timeline().Global(timeline.GlobalRequest{Limit: 10})
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "timeline").Warning(err)
return return
} }
misskeyGlobalTimelineResponseTime.Observe(float64(time.Since(start).Milliseconds()) / 1000) t := float64(time.Since(start).Milliseconds()) / 1000
misskeyGlobalTimelineResponseTimeRaw.Set(float64(time.Since(start).Milliseconds()) / 1000) misskeyGlobalTimelineResponseTime.Observe(t)
misskeyGlobalTimelineResponseTimeRaw.Set(t)
misskeyApiResponseTime.WithLabelValues("timeline", "global").Observe(t)
misskeyApiResponseTimeRaw.WithLabelValues("timeline", "global").Set(t)
if len(global) != 0 { if len(global) != 0 {
misskeyGlobalTimelineLastNotePublished.Set(float64(global[0].CreatedAt.UnixMilli())) misskeyGlobalTimelineLastNotePublished.Set(float64(global[0].CreatedAt.UnixMilli()))
} }
@ -133,15 +139,50 @@ func collectTimeline() {
start := time.Now() start := time.Now()
global, err := client.Notes().Timeline().Local(timeline.LocalRequest{Limit: 10}) global, err := client.Notes().Timeline().Local(timeline.LocalRequest{Limit: 10})
if err != nil { if err != nil {
logrus.Warning(err) logrus.WithField("type", "timeline").Warning(err)
return return
} }
misskeyLocalTimelineResponseTime.Observe(float64(time.Since(start).Milliseconds()) / 1000) t := float64(time.Since(start).Milliseconds()) / 1000
misskeyLocalTimelineResponseTimeRaw.Set(float64(time.Since(start).Milliseconds()) / 1000) misskeyLocalTimelineResponseTime.Observe(t)
misskeyLocalTimelineResponseTimeRaw.Set(t)
misskeyApiResponseTime.WithLabelValues("timeline", "local").Observe(t)
misskeyApiResponseTimeRaw.WithLabelValues("timeline", "local").Set(t)
if len(global) != 0 { if len(global) != 0 {
misskeyLocalTimelineLastNotePublished.Set(float64(global[0].CreatedAt.UnixMilli())) misskeyLocalTimelineLastNotePublished.Set(float64(global[0].CreatedAt.UnixMilli()))
} }
}() }()
go func() {
start := time.Now()
global, err := client.Notes().Timeline().Get(timeline.GetRequest{Limit: 10})
if err != nil {
logrus.WithField("type", "timeline").Warning(err)
return
}
t := float64(time.Since(start).Milliseconds()) / 1000
misskeyHomeTimelineResponseTime.Observe(t)
misskeyHomeTimelineResponseTimeRaw.Set(t)
misskeyApiResponseTime.WithLabelValues("timeline", "home").Observe(t)
misskeyApiResponseTimeRaw.WithLabelValues("timeline", "home").Set(t)
if len(global) != 0 {
misskeyHomeTimelineLastNotePublished.Set(float64(global[0].CreatedAt.UnixMilli()))
}
}()
go func() {
start := time.Now()
global, err := client.Notes().Timeline().Hybrid(timeline.HybridRequest{Limit: 10})
if err != nil {
logrus.WithField("type", "timeline").Warning(err)
return
}
t := float64(time.Since(start).Milliseconds()) / 1000
misskeySocialTimelineResponseTime.Observe(t)
misskeySocialTimelineResponseTimeRaw.Set(t)
misskeyApiResponseTime.WithLabelValues("timeline", "social").Observe(t)
misskeyApiResponseTimeRaw.WithLabelValues("timeline", "social").Set(t)
if len(global) != 0 {
misskeySocialTimelineLastNotePublished.Set(float64(global[0].CreatedAt.UnixMilli()))
}
}()
} }
} }

982
dashboards.json Normal file
View File

@ -0,0 +1,982 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 2,
"id": 1,
"links": [],
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"fieldMinMax": false,
"mappings": [
{
"options": {
"0": {
"index": 1,
"text": "DOWN"
},
"1": {
"index": 0,
"text": "UP"
}
},
"type": "value"
}
],
"noValue": "UNKNOWN",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red"
},
{
"color": "red",
"value": 0
},
{
"color": "green",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 3,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "misskey_health",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Health",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"fieldMinMax": false,
"mappings": [
{
"options": {
"0": {
"index": 1,
"text": "DOWN"
},
"1": {
"index": 0,
"text": "UP"
}
},
"type": "value"
}
],
"noValue": "UNKNOWN",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red"
},
{
"color": "red",
"value": 0
},
{
"color": "green",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 3,
"x": 3,
"y": 0
},
"id": 7,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "value",
"wideLayout": true
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "up",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "__auto",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Exporter Health",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"decimals": 1,
"fieldMinMax": false,
"mappings": [],
"max": 100,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red"
},
{
"color": "green",
"value": 98
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 3,
"x": 6,
"y": 0
},
"id": 2,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "horizontal",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "value",
"wideLayout": true
},
"pluginVersion": "11.6.0",
"targets": [
{
"editorMode": "code",
"exemplar": false,
"expr": "100 * (sum_over_time(misskey_health[30d]) / count_over_time(misskey_health[30d]))",
"format": "time_series",
"instant": false,
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "Availability(30d)",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 3,
"x": 9,
"y": 0
},
"id": 5,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.6.0",
"targets": [
{
"editorMode": "code",
"expr": "misskey_online_users",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "Online Users",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"fieldMinMax": true,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text"
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 6,
"x": 12,
"y": 0
},
"id": 3,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "same_as_value",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": true,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.6.0",
"targets": [
{
"editorMode": "builder",
"expr": "misskey_notes_count",
"instant": false,
"legendFormat": "All",
"range": true,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"editorMode": "builder",
"exemplar": false,
"expr": "misskey_original_notes_count",
"hide": false,
"instant": false,
"legendFormat": "Local",
"range": true,
"refId": "B"
}
],
"title": "Note Count",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"fieldMinMax": true,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "text"
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 6,
"x": 18,
"y": 0
},
"id": 4,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "same_as_value",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": true,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.6.0",
"targets": [
{
"editorMode": "code",
"expr": "misskey_users_count",
"legendFormat": "All",
"range": true,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"editorMode": "code",
"expr": "misskey_original_users_count",
"hide": false,
"instant": false,
"legendFormat": "Local",
"range": true,
"refId": "B"
}
],
"title": "User Count",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineStyle": {
"fill": "solid"
},
"lineWidth": 1,
"pointSize": 1,
"scaleDistribution": {
"log": 2,
"type": "log"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "dashed+area"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "#EAB839",
"value": 0.2
},
{
"color": "orange",
"value": 1
},
{
"color": "red",
"value": 2
}
]
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 11,
"w": 12,
"x": 0,
"y": 6
},
"id": 6,
"options": {
"legend": {
"calcs": [
"last",
"min",
"max",
"median"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"disableTextWrap": false,
"editorMode": "builder",
"exemplar": false,
"expr": "histogram_quantile(0.99, sum by(api, type, le) (rate(misskey_api_response_time_bucket[$__rate_interval])))",
"format": "time_series",
"fullMetaSearch": false,
"hide": false,
"includeNullMetadata": false,
"instant": false,
"interval": "",
"legendFormat": "{{api}} {{type}}",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "API Response Time(99%PCTL)",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineStyle": {
"fill": "solid"
},
"lineWidth": 1,
"pointSize": 1,
"scaleDistribution": {
"log": 2,
"type": "log"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "dashed+area"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "#EAB839",
"value": 0.2
},
{
"color": "orange",
"value": 1
},
{
"color": "red",
"value": 2
}
]
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 11,
"w": 12,
"x": 12,
"y": 6
},
"id": 8,
"options": {
"legend": {
"calcs": [
"last",
"min",
"max",
"median"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "misskey_api_response_time_raw",
"fullMetaSearch": false,
"hide": false,
"includeNullMetadata": false,
"instant": false,
"legendFormat": "{{api}} {{type}}",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "API Response Time(RAW)",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "orange",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 17
},
"id": 9,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "value_and_name",
"wideLayout": true
},
"pluginVersion": "11.6.0",
"targets": [
{
"disableTextWrap": false,
"editorMode": "builder",
"expr": "sum by(status) (misskey_jobqueue_jobs{type=\"deliver\"})",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "{{type}} {{status}}",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Deliver",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "orange",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 17
},
"id": 10,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "value_and_name",
"wideLayout": true
},
"pluginVersion": "11.6.0",
"targets": [
{
"disableTextWrap": false,
"editorMode": "builder",
"expr": "sum by(status) (misskey_jobqueue_jobs{type=\"inbox\"})",
"fullMetaSearch": false,
"includeNullMetadata": true,
"legendFormat": "{{type}} {{status}}",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Inbox",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "cej25be7w5af4e"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "dashed+area"
}
},
"decimals": 0,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 18,
"w": 24,
"x": 0,
"y": 25
},
"id": 11,
"options": {
"legend": {
"calcs": [
"max"
],
"displayMode": "table",
"placement": "right",
"showLegend": true,
"sortBy": "Max",
"sortDesc": true
},
"tooltip": {
"hideZeros": false,
"mode": "multi",
"sort": "desc"
}
},
"pluginVersion": "11.6.0",
"targets": [
{
"disableTextWrap": false,
"editorMode": "builder",
"expr": "misskey_jobqueue_jobs",
"fullMetaSearch": false,
"includeNullMetadata": true,
"interval": "1",
"legendFormat": "{{type}} {{status}}",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Job Queue",
"type": "timeseries"
}
],
"preload": false,
"refresh": "auto",
"schemaVersion": 41,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-15m",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "New dashboard",
"uid": "eej5avfu4yyo0f",
"version": 25
}

View File

@ -10,8 +10,9 @@ services:
image: prom/prometheus image: prom/prometheus
volumes: volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml - ./prometheus.yml:/etc/prometheus/prometheus.yml
- ./rules.yaml:/etc/prometheus/rules.yaml
ports: ports:
- 9090:9090 - "9090:9090"
grafana: grafana:
image: grafana/grafana-enterprise image: grafana/grafana-enterprise
ports: ports:

55
main.go
View File

@ -100,6 +100,53 @@ var (
Name: "misskey_local_timeline_response_time_raw", Name: "misskey_local_timeline_response_time_raw",
Help: "Response Time for misskey Local Timeline", Help: "Response Time for misskey Local Timeline",
}) })
misskeyHomeTimelineResponseTime = prometheus.NewHistogram(
prometheus.HistogramOpts{
Name: "misskey_home_timeline_response_time",
Help: "Response Time for misskey Home Timeline",
})
misskeyHomeTimelineResponseTimeRaw = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "misskey_home_timeline_response_time_raw",
Help: "Response Time for misskey Home Timeline",
})
misskeyHomeTimelineLastNotePublished = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "misskey_home_timeline_last_note_published",
Help: "Last Note Published on Home Timeline",
},
)
misskeySocialTimelineResponseTime = prometheus.NewHistogram(
prometheus.HistogramOpts{
Name: "misskey_social_timeline_response_time",
Help: "Response Time for misskey Home Timeline",
})
misskeySocialTimelineResponseTimeRaw = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "misskey_social_timeline_response_time_raw",
Help: "Response Time for misskey Home Timeline",
})
misskeySocialTimelineLastNotePublished = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "misskey_social_timeline_last_note_published",
Help: "Last Note Published on Home Timeline",
},
)
misskeyApiResponseTime = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "misskey_api_response_time",
Help: "Response Time for misskey API",
Buckets: prometheus.DefBuckets,
},
[]string{"type", "api"},
)
misskeyApiResponseTimeRaw = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "misskey_api_response_time_raw",
Help: "Response Time for misskey API",
},
[]string{"type", "api"},
)
misskeyOnlineUsers = prometheus.NewGauge( misskeyOnlineUsers = prometheus.NewGauge(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "misskey_online_users", Name: "misskey_online_users",
@ -139,6 +186,14 @@ func main() {
prometheus.MustRegister(misskeyLocalTimelineLastNotePublished) prometheus.MustRegister(misskeyLocalTimelineLastNotePublished)
prometheus.MustRegister(misskeyGlobalTimelineResponseTimeRaw) prometheus.MustRegister(misskeyGlobalTimelineResponseTimeRaw)
prometheus.MustRegister(misskeyLocalTimelineResponseTimeRaw) prometheus.MustRegister(misskeyLocalTimelineResponseTimeRaw)
prometheus.MustRegister(misskeyHomeTimelineResponseTime)
prometheus.MustRegister(misskeyHomeTimelineResponseTimeRaw)
prometheus.MustRegister(misskeyHomeTimelineLastNotePublished)
prometheus.MustRegister(misskeySocialTimelineResponseTime)
prometheus.MustRegister(misskeySocialTimelineResponseTimeRaw)
prometheus.MustRegister(misskeySocialTimelineLastNotePublished)
prometheus.MustRegister(misskeyApiResponseTime)
prometheus.MustRegister(misskeyApiResponseTimeRaw)
prometheus.MustRegister(misskeyOnlineUsers) prometheus.MustRegister(misskeyOnlineUsers)
handler := promhttp.Handler() handler := promhttp.Handler()

View File

@ -5,3 +5,5 @@ scrape_configs:
- job_name: 'process_exporter' - job_name: 'process_exporter'
static_configs: static_configs:
- targets: ['misskey-exporter:8080'] - targets: ['misskey-exporter:8080']
rule_files:
- rules.yaml

6
rules.yaml Normal file
View File

@ -0,0 +1,6 @@
groups:
- name: misskey_health
interval: 1m
rules:
- record: misskey_health
expr: clamp_max(count_over_time(misskey_ping_response_code[1m]), 1)