首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过具有datadog模拟角色的日志文件的位置检测datadog代理

通过具有datadog模拟角色的日志文件的位置检测datadog代理
EN

Stack Overflow用户
提问于 2021-05-04 00:58:12
回答 1查看 167关注 0票数 0

我尝试使用datadog ansible角色启用日志收集,

但是我不明白为什么日志没有报告给Datadog ui

我在github存储库中找到了一个剧本的例子,

代码语言:javascript
复制
- hosts: servers
  roles:
    - { role: datadog.datadog, become: yes }
  vars:
    datadog_api_key: "<YOUR_DD_API_KEY>"
    datadog_agent_version: "7.16.0"
    datadog_config:
      tags:
        - "<KEY>:<VALUE>"
        - "<KEY>:<VALUE>"
      log_level: INFO
      apm_config:
        enabled: true
      logs_enabled: true  # available with Agent v6 and v7
    datadog_checks:
      process:
        init_config:
        instances:
          - name: ssh
            search_string: ['ssh', 'sshd' ]
          - name: syslog
            search_string: ['rsyslog' ]
            cpu_check_interval: 0.2
            exact_match: true
            ignore_denied_access: true
      ssh_check:
        init_config:
        instances:
          - host: localhost
            port: 22
            username: root
            password: <YOUR_PASSWORD>
            sftp_check: True
            private_key_file:
            add_missing_keys: True
      nginx:
        init_config:
        instances:
          - nginx_status_url: http://example.com/nginx_status/
            tags:
              - "source:nginx"
              - "instance:foo"
          - nginx_status_url: http://example2.com:1234/nginx_status/
            tags:
              - "source:nginx"
              - "<KEY>:<VALUE>"

        #Log collection is available on Agent 6 and 7
        logs:
          - type: file
            path: /var/log/access.log
            service: myapp
            source: nginx
            sourcecategory: http_web_access
          - type: file
            path: /var/log/error.log
            service: nginx
            source: nginx
            sourcecategory: http_web_access
    # datadog_integration is available on Agent 6.8+
    datadog_integration:
      datadog-elastic:
        action: install
        version: 1.11.0
      datadog-postgres:
        action: remove
    network_config:
      enabled: true

但是,对于我的情况,我只有一个tomcat服务器在记录一个文件,我想让datadog将这些日志文件带到我的datadog帐户,我该如何做呢?

提前感谢

代码语言:javascript
复制
# my code
- name: install the agent on targets
          include_role:
            name: datadog.datadog
          vars: 
            datadog_api_key: "myApiKey"
            datadog_site: "datadoghq.com"
            datadog_config:
              log_level: INFO
              apm_config:
                enabled: true
              logs_enabled: true
              logs:
                - type: file
                  path: /home/ubuntu/web-app/tomcatlogs/logs/*.log
                  service: myapp
                  source: tomcat

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-04 18:15:35

我想我该怎么做,

如果您处于相同的情况,请检查此代码

最重要的是指定一个服务(tomcat、nginx、java ...)Ansible角色将尝试创建完成配置所需的文件,

代码语言:javascript
复制
- name: install the agent on targets
      include_role:
        name: datadog.datadog
      vars: 
        datadog_api_key: "YOUR_API"
        datadog_site: "datadoghq.com"
        datadog_config:
          log_level: INFO
          apm_config:
            enabled: true
          logs_enabled: true
        datadog_checks:
          tomcat:
            logs:
              - type: file
                path: /home/ubuntu/web-app/tomcatlogs/logs/*.log
                service: myapp
                source: tomcat
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67372864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档