Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update postgresql dashboard and alert rules based on categraf acquis… #1613

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"cate": "prometheus",
"datasource_ids": [
1
0
],
"name": "posgresql读取时间过高",
"note": "数据库中花费在读取文件的时间,这个值很高说明内存较小,需要频繁从磁盘读入数据文件",
Expand Down Expand Up @@ -68,7 +68,7 @@
{
"cate": "prometheus",
"datasource_ids": [
1
0
],
"name": "Postgresql down",
"note": "",
Expand Down Expand Up @@ -134,7 +134,7 @@
{
"cate": "prometheus",
"datasource_ids": [
1
0
],
"name": "postgresql写入时间过高",
"note": "数据库中花费在写数据文件的时间,pg中脏页一般写入page cache,如果这个值较高,则说明cache较小,操作系统的cache需要更积极的写入",
Expand Down Expand Up @@ -200,7 +200,7 @@
{
"cate": "prometheus",
"datasource_ids": [
1
0
],
"name": "postgresql有死锁",
"note": "",
Expand Down Expand Up @@ -266,7 +266,7 @@
{
"cate": "prometheus",
"datasource_ids": [
1
0
],
"name": "Postgresql缓存命中率低于50%",
"note": "",
Expand Down Expand Up @@ -329,4 +329,4 @@
"append_tags": [],
"annotations": {}
}
]
]
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
{
"name": "postgresql大盘",
"tags": "",
"name": "postgresql by categraf",
"tags": "categraf",
"ident": "",
"configs": {
"var": [
{
"name": "datasource",
"type": "datasource",
"definition": "prometheus",
"defaultValue": 5
},
{
"name": "server",
"type": "query",
"definition": "label_values(postgresql_datid,server)"
"definition": "label_values(postgresql_datid,server)",
"datasource": {
"cate": "prometheus",
"value": "${datasource}"
}
},
{
"name": "db",
"type": "query",
"definition": "label_values(postgresql_datid{server=\"$server\"},db)"
"definition": "label_values(postgresql_datid{server=\"$server\"},db)",
"datasource": {
"cate": "prometheus",
"value": "${datasource}"
}
}
],
"panels": [
Expand All @@ -35,7 +50,7 @@
"id": "65571b64-d249-40f1-8c57-ef826118c7a9",
"layout": {
"h": 4,
"w": 5,
"w": 6,
"x": 0,
"y": 1,
"i": "65571b64-d249-40f1-8c57-ef826118c7a9",
Expand Down Expand Up @@ -73,15 +88,16 @@
}
]
}
}
},
"datasourceValue": "${datasource}"
},
{
"type": "stat",
"id": "bdf5299c-b621-4d98-bcf8-fa2ebd12b7d4",
"layout": {
"h": 4,
"w": 5,
"x": 5,
"w": 6,
"x": 6,
"y": 1,
"i": "0fb92b82-63c4-4edd-a452-fb51150757ab",
"isResizable": true
Expand Down Expand Up @@ -121,15 +137,16 @@
}
]
}
}
},
"datasourceValue": "${datasource}"
},
{
"type": "stat",
"id": "2a559648-ad51-40d1-a6ff-f641467b57ea",
"layout": {
"h": 4,
"w": 5,
"x": 10,
"w": 6,
"x": 12,
"y": 1,
"i": "d78ae395-1d53-481a-9566-9f4913616330",
"isResizable": true
Expand Down Expand Up @@ -169,15 +186,16 @@
}
]
}
}
},
"datasourceValue": "${datasource}"
},
{
"type": "stat",
"id": "87a74ec2-c6d2-49e8-a1ea-4dbf1252a33d",
"layout": {
"h": 4,
"w": 5,
"x": 15,
"w": 6,
"x": 18,
"y": 1,
"i": "a666823e-455f-459e-bbfe-169341b77ddc",
"isResizable": true
Expand Down Expand Up @@ -217,7 +235,8 @@
}
]
}
}
},
"datasourceValue": "${datasource}"
},
{
"targets": [
Expand Down Expand Up @@ -271,7 +290,9 @@
"i": "443aee8c-d1b8-485b-b74f-13fa58b6e7ae",
"isResizable": true
},
"id": "3dea2872-5904-4abf-b0f8-64afe82b617a"
"id": "3dea2872-5904-4abf-b0f8-64afe82b617a",
"datasourceCate": "prometheus",
"datasourceValue": "${datasource}"
},
{
"targets": [
Expand Down Expand Up @@ -325,7 +346,9 @@
"i": "8b85bc95-091a-4868-9bec-b495609d7a04",
"isResizable": true
},
"id": "dec2c25d-ae70-4e47-bc4f-6dbaa9e72683"
"id": "dec2c25d-ae70-4e47-bc4f-6dbaa9e72683",
"datasourceCate": "prometheus",
"datasourceValue": "${datasource}"
},
{
"targets": [
Expand Down Expand Up @@ -384,7 +407,9 @@
"i": "e08d94bb-1a72-4104-8ba0-11ab7317a192",
"isResizable": true
},
"id": "048d2652-40f1-42ab-a435-7e02d51c98c4"
"id": "048d2652-40f1-42ab-a435-7e02d51c98c4",
"datasourceCate": "prometheus",
"datasourceValue": "${datasource}"
},
{
"targets": [
Expand Down Expand Up @@ -438,7 +463,9 @@
"i": "971c5838-7408-4ec7-ae5e-33dcd0f20210",
"isResizable": true
},
"id": "c89d1e4b-d8ad-402d-bee4-f6d362b4634a"
"id": "c89d1e4b-d8ad-402d-bee4-f6d362b4634a",
"datasourceCate": "prometheus",
"datasourceValue": "${datasource}"
},
{
"targets": [
Expand Down Expand Up @@ -494,7 +521,9 @@
"i": "71e28edd-8961-4a7a-be78-3a9a526c89bb",
"isResizable": true
},
"id": "7ae2c26a-cc2b-435d-9a16-52722c37bedf"
"id": "7ae2c26a-cc2b-435d-9a16-52722c37bedf",
"datasourceCate": "prometheus",
"datasourceValue": "${datasource}"
},
{
"type": "row",
Expand Down Expand Up @@ -564,7 +593,9 @@
"i": "c3d3ccee-719f-4280-8921-367ea5343849",
"isResizable": true
},
"id": "600a9687-0a1e-4531-b9bc-ccf8589566a2"
"id": "600a9687-0a1e-4531-b9bc-ccf8589566a2",
"datasourceCate": "prometheus",
"datasourceValue": "${datasource}"
},
{
"targets": [
Expand Down Expand Up @@ -620,7 +651,9 @@
"i": "178d8220-3c22-4ea3-909d-71c73fbb3a78",
"isResizable": true
},
"id": "561012f8-481a-482a-8504-4bdd8c62e8a6"
"id": "561012f8-481a-482a-8504-4bdd8c62e8a6",
"datasourceCate": "prometheus",
"datasourceValue": "${datasource}"
},
{
"targets": [
Expand Down Expand Up @@ -686,9 +719,18 @@
"i": "23b6fc64-1a19-422e-b28e-453570af339c",
"isResizable": true
},
"id": "af9e2a7f-ce09-4de2-8625-e779c770d46d"
"id": "af9e2a7f-ce09-4de2-8625-e779c770d46d",
"datasourceCate": "prometheus",
"datasourceValue": "${datasource}"
}
],
"version": "2.0.0"
"version": "3.0.0",
"links": [
{
"title": "文档",
"url": "https://github.com/ccfos/nightingale/tree/main/integrations/postgresql/markdown/",
"targetBlank": true
}
]
}
}
Binary file modified integrations/postgresql/icon/postgresql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions integrations/postgresql/markdown/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## PostgreSQL Dashboard & Alerts

使用[categraf](https://github.com/flashcatcloud/categraf)中[inputs.postgresql](https://github.com/flashcatcloud/categraf/tree/main/inputs/postgresql)插件采集[PostgreSQL](https://www.postgresql.org/)服务监控指标数据;

### 配置文件示例:

如果是多个PostgreSQL,可以写多个[[instance]]配置

```toml
[[instances]]
address = "host=192.168.11.181 port=5432 user=postgres password=123456789 sslmode=disable"
## specify address via a url matching:
## postgres://[pqgotest[:password]]@localhost[/dbname]?sslmode=[disable|verify-ca|verify-full]
## or a simple string:
## host=localhost user=pqgotest password=... sslmode=... dbname=app_production
##
## All connection parameters are optional.
##
## Without the dbname parameter, the driver will default to a database
## with the same name as the user. This dbname is just for instantiating a
## connection with the server and doesn't restrict the databases we are trying
## to grab metrics for.
##
# address = "host=localhost user=postgres sslmode=disable"

## A custom name for the database that will be used as the "server" tag in the
## measurement output. If not specified, a default one generated from
## the connection address is used.
# outputaddress = "db01"

## connection configuration.
## maxlifetime - specify the maximum lifetime of a connection.
## default is forever (0s)
# max_lifetime = "0s"

## A list of databases to explicitly ignore. If not specified, metrics for all
## databases are gathered. Do NOT use with the 'databases' option.
# ignored_databases = ["postgres", "template0", "template1"]

## A list of databases to pull metrics about. If not specified, metrics for all
## databases are gathered. Do NOT use with the 'ignored_databases' option.
# databases = ["app_production", "testing"]

## Whether to use prepared statements when connecting to the database.
## This should be set to false when connecting through a PgBouncer instance
## with pool_mode set to transaction.
#prepared_statements = true
# [[instances.metrics]]
# mesurement = "sessions"
# label_fields = [ "status", "type" ]
# metric_fields = [ "value" ]
# timeout = "3s"
# request = '''
# SELECT status, type, COUNT(*) as value FROM v$session GROUP BY status, type
# '''
```

### 告警规则

![alert](./alerts.png)

[alerts](../alerts/postgresql_by_categraf.json)

### 仪表盘:

![dashboard](./postgresql.png)

[dashboard](../dashboards/postgresql_by_categraf.json)
Binary file added integrations/postgresql/markdown/alerts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added integrations/postgresql/markdown/postgresql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.