我使用在主机(而非docker)上运行的datadog代理6.9, 并且我还在主机上运行了几个应用程序(docker映像)。
我尝试避免将特定的日志从mongodb发送到datadoghq。 因此,根据https://docs.datadoghq.com/logs/log_collection/?tab=tailexistingfiles 我在其中创建mongo.d目录和conf.yaml,如下所示:
init_config:
instances:
# Specify the MongoDB URI, with database to use for reporting (defaults to "admin")
# E.g. mongodb://datadog:LnCbkX4uhpuLHSUrcayEoAZA@localhost:27016/my-db
- server: mongodb://datadog:LnCbkX4uhpuLHSUrcayEoAZA@localhost:27016/my-db
# Controls connectTimeoutMS, serverSelectionTimeoutMS and socketTimeoutMS (see http://api.mongodb.com/python/3.4.0/api/pymongo/mongo_client.html)
# Defaults to 30 seconds
# timeout: 30
# tags:
# - optional_tag1
# - optional_tag2
# Whether or not to read from available replicas (default true).
# Disable this if any replicas are inaccessible to the agent.
replica_check: true
# Optional SSL parameters, see https://github.com/mongodb/mongo-python-driver/blob/2.6.3/pymongo/mongo_client.py#L193-L212
# for more details
#
# ssl: True # Optional (default to False)
# ssl_keyfile: # Path to the private keyfile used to identify the local
# ssl_certfile: # Path to the certificate file used to identify the local connection against mongod.
# ssl_cert_reqs: 0 # Specifies whether a certificate is required from the other side of the connection, and whether it will be validated if provided.
# Possible values:
# * 0 for ssl.CERT_NONE (certificates ignored)
# * 1 for ssl.CERT_OPTIONAL (not required, but validated if provided)
# * 2 for ssl.CERT_REQUIRED (required and validated)
# ssl_ca_certs: # Path to the ca_certs file
#
# By default, the check collects a sample of metrics from MongoDB.
# The (optional) `additional_metrics` parameter instructs the check to collect additional
# metrics on specific topics.
# Available options are:
# * `metrics.commands` - Use of database commands
# * `tcmalloc` - TCMalloc memory allocator
# * `top` - Usage statistics for each collection
# * `collection` - Metrics of the specified collections
additional_metrics:
- metrics.commands
- tcmalloc
- top
- collection
#
# Collect metrics on specific collections from the database specified
# Requires `additional_metrics.collection` to be present
# Metrics such as `mongodb.collection.count` will be collected for each named collection and tagged as follows:
# - `db:<dbname>` e.g. `db:my-db`
# - `collection:<collection-name>` e.g. `collection:my_collection`
# Each collection generates many metrics,
# up to 8 + the number of indices on the collection for each collection
collections:
- apples
- oranges
# Collect indexes access metrics for every index in every collections in
# the 'collections' list. This is available starting mongo 3.2.
# collections_indexes_stats: false
## Log section (Available for Agent >=6.0)
logs:
# - type : (mandatory) type of log input source (tcp / udp / file)
# port / path : (mandatory) Set port if type is tcp or udp. Set path if type is file
# service : (mandatory) name of the service owning the log
# source : (mandatory) attribute that defines which integration is sending the logs
# sourcecategory : (optional) Multiple value attribute. Can be used to refine the source attribtue
# tags: (optional) add tags to each logs collected
# - type: file
# path: /var/log/mongodb/mongodb.log
# service: mongo
# source: mongodb
- type: docker
service: mongo
source: mongodb
log_processing_rules:
- type: exclude_at_match
name: exclude_mongo
pattern: (?s).*
但是当我重新启动代理时,它仍然会将不需要的日志发送到我的datadoghq。
预先感谢您的帮助, 巴鲁克