- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
To collect custom metrics with the Postgres integration, use the custom_queries
option in the conf.d/postgres.d/conf.yaml
file at the root of your Agent’s configuration directory. See the sample postgres.d/conf.yaml for more details.
Note: When generating custom metrics that require querying additional tables, you may need to grant the SELECT
permission on those tables to the Postgres user. Example: grant SELECT on <TABLE_NAME> to <USER>;
custom_queries
has the following options:
metric_prefix
query
columns
name
: The suffix to append to the metric_prefix
to form the full metric name. If the type
is specified as tag
, the column is instead applied as a tag to every metric collected by this query.type
: The submission method (for example, gauge
, count
, rate
, etc.). This can also be set to tag
to tag each metric in the row with the name and value (<name>:<row_value>
) of the item in this column.tags
At least one of the items in defined columns
should be a metric type (gauge
, count
, rate
, etc.). For more information about metrics submission from an Agent Check, see Metrics Types.
The number of items defined in columns
must equal the number of columns returned in the query.
The order in which the items in columns
are defined must be same order returned in the query.
custom_queries:
- query: Select F3, F2, F1 from Table;
columns:
- {name: f3_metric_alias, type: gauge}
- {name: f2_tagkey , type: tag }
- {name: f1_metric_alias, type: count}
[...]
Below is the company
table from testdb
database. The table contains 3 employee records:
testdb=# SELECT * FROM company;
id| name | age| address |salary | entry_date | last_raise_time
-------------------------------------------------------------------
1 | Paul | 32 | California | 20000 | 1457570000 | 1457570300
2 | Allen | 25 | Texas | 30000 | 1457570060 | 1457570300
3 | Teddy | 23 | Norway | 45000 | 1457570120 | 1457570300
The goal is to capture the age and salary of Paul as metric values with his name and address as tags.
SQL query:
SELECT age,salary,name,address FROM company WHERE name = 'Paul'
Corresponding custom_queries
YAML configuration:
custom_queries:
- metric_prefix: postgresql
query: SELECT age,salary,name,address FROM company WHERE name = 'Paul'
columns:
- name: employee_age
type: gauge
- name: employee_salary
type: gauge
- name: name
type: tag
- name: localisation
type: tag
tags:
- query:custom
After updating the Postgres YAML file, restart the Datadog Agent.
To verify the result, search for the metrics using the Metrics Explorer:
Run the Agent’s status subcommand and look for postgres
under the Checks section:
postgres
--------
- instance #0 [ERROR]: 'Missing metric_prefix parameter in custom_queries'
- Collected 0 metrics, 0 events & 0 service checks
Additionally, the Agent’s logs may provide useful information.
추가 유용한 문서, 링크 및 기사: