disabled: no

discoverer:
  docker:
    address: "unix:///var/run/docker.sock"

services:
  - id: "skip"
    match: |
      {{ $netNOK := eq .NetworkMode "host" -}}
      {{ $protoNOK := not (eq .PortProtocol "tcp") -}}
      {{ $portNOK := empty .PrivatePort -}}
      {{ $addrNOK := or (empty .IPAddress) (glob .PublicPortIP "*:*") -}}
      {{ or $netNOK $protoNOK $portNOK $addrNOK }}

  - id: "apache"
    match: '{{ match "sp" .Image "httpd httpd:* */apache */apache:* */apache2 */apache2:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}/server-status?auto

  - id: "beanstalk"
    match: '{{ match "sp" .Image "*/beanstalkd */beanstalkd:*" }}'
    config_template: |
      name: docker_{{.Name}}
      address: {{.Address}}

  - id: "boinc"
    match: '{{ match "sp" .Image "boinc/client boinc/client:* */boinc */boinc:*" }}'
    config_template: |
      name: docker_{{.Name}}
      address: {{.Address}}

  - id: "cockroachdb"
    match: '{{ match "sp" .Image "cockroachdb/cockroach cockroachdb/cockroach:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}/_status/vars

  - id: "consul"
    match: '{{ match "sp" .Image "consul consul:* */consul */consul:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}

  - id: "coredns"
    match: '{{ match "sp" .Image "*/coredns */coredns:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}/metrics

  - id: "couchbase"
    match: '{{ or (eq .PrivatePort "8091") (match "sp" .Image "couchbase couchbase:*") }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}

  - id: "couchdb"
    match: '{{ or (eq .PrivatePort "5984") (match "sp" .Image "couchdb couchdb:*") }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}

  - id: "dovecot"
    match: '{{ or (eq .PrivatePort "24242") (match "sp" .Image "*/dovecot */dovecot:*") }}'
    config_template: |
      name: docker_{{.Name}}
      address: {{.Address}}

  - id: "elasticsearch"
    match: '{{ or (eq .PrivatePort "9200") (match "sp" .Image "elasticsearch elasticsearch:* */elasticsearch */elasticsearch:* */opensearch */opensearch:*") }}'
    config_template: |
      name: docker_{{.Name}}
      {{ if glob .Image "*elastic*" -}}
      url: http://{{.Address}}
      {{ else -}}
      url: https://{{.Address}}
      tls_skip_verify: yes
      username: admin
      password: admin
      {{ end -}}

  - id: "gearman"
    match: '{{ and (eq .PrivatePort "4730") (match "sp" .Image "*/gearmand */gearmand:*") }}'
    config_template: |
      name: docker_{{.Name}}
      address: {{.Address}}

  - id: "ipfs"
    match: '{{ and (eq .PrivatePort "5001") (match "sp" .Image "ipfs/kubo ipfs/kubo:*") }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}

  - id: "lighttpd"
    match: '{{ match "sp" .Image "*/lighttpd */lighttpd:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}/server-status?auto

  - id: "maxscale"
    match: '{{ or (eq .PrivatePort "8989") (match "sp" .Image "mariadb/maxscale mariadb/maxscale:*") }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}

  - id: "memcached"
    match: '{{ or (eq .PrivatePort "11211") (match "sp" .Image "memcached memcached:* */memcached */memcached:*") }}'
    config_template: |
      name: docker_{{.Name}}
      address: {{.Address}}

  - id: "mongodb"
    match: '{{ or (eq .PrivatePort "27017") (match "sp" .Image "mongo mongo:* */mongodb */mongodb:* */mongodb-community-server */mongodb-community-server:*") }}'
    config_template: |
      name: docker_{{.Name}}
      uri: mongodb://{{.Address}}

  - id: "mysql"
    match: '{{ or (eq .PrivatePort "3306") (match "sp" .Image "mysql mysql:* */mysql */mysql:* mariadb mariadb:* */mariadb */mariadb:* percona percona:* */percona-mysql */percona-mysql:*") }}'
    config_template: |
      name: docker_{{.Name}}
      dsn: netdata@tcp({{.Address}})/

  - id: "nats"
    match: '{{ and (eq .PrivatePort "8222") (match "sp" .Image "nats nats:*") }}'
    config_template: |
      - name: docker_{{.Name}}
        url: http://{{.Address}}

  - id: "nginx"
    match: '{{ match "sp" .Image "nginx nginx:*" }}'
    config_template: |
      - name: docker_{{.Name}}
        url: http://{{.Address}}/stub_status
      - name: docker_{{.Name}}
        url: http://{{.Address}}/basic_status
      - name: docker_{{.Name}}
        url: http://{{.Address}}/nginx_status
      - name: docker_{{.Name}}
        url: http://{{.Address}}/status

  - id: "nginxunit"
    match: '{{ match "sp" .Image "nginx/unit nginx/unit:*" }}'
    config_template: |
      - name: docker_{{.Name}}
        url: http://{{.Address}}

  - id: "oracledb"
    match: '{{ and (eq .PrivatePort "1521" "2484") (match "sp" .Image "oracle/database oracle/database:*") }}'
    config_template: |
      name: docker_{{.Name}}
      {{ if eq .PrivatePort "1521" -}}
      dsn: 'oracle://username:password@{{.Address}}/XE'
      {{ else -}}
      dsn: 'oracle://username:password@{{.Address}}/XE?ssl=true&ssl verify=false'
      {{ end -}}

  - id: "pgbouncer"
    match: '{{ or (eq .PrivatePort "6432") (match "sp" .Image "*/pgbouncer */pgbouncer:*") }}'
    config_template: |
      name: docker_{{.Name}}
      dsn: postgres://netdata:postgres@{{.Address}}/pgbouncer

  - id: "pika"
    match: '{{ match "sp" .Image "pikadb/pika pikadb/pika:*" }}'
    config_template: |
      name: docker_{{.Name}}
      address: redis://@{{.Address}}

  - id: "postgres"
    match: '{{ or (eq .PrivatePort "5432") (match "sp" .Image "postgres postgres:* */postgres */postgres:* */postgresql */postgresql:*") }}'
    config_template: |
      module: postgres
      name: docker_{{.Name}}
      dsn: postgres://netdata:postgres@{{.Address}}/postgres

  - id: "proxysql"
    match: '{{ or (eq .PrivatePort "6032") (match "sp" .Image "*/proxysql */proxysql:*") }}'
    config_template: |
      name: docker_{{.Name}}
      dsn: stats:stats@tcp({{.Address}})/

  - id: "puppet"
    match: '{{ or (eq .PrivatePort "8140") (match "sp" .Image "puppet/puppetserver puppet/puppetserver:*") }}'
    config_template: |
      name: docker_{{.Name}}
      url: https://{{.Address}}
      tls_skip_verify: yes

  - id: "rabbitmq"
    match: '{{ or (eq .PrivatePort "15672") (match "sp" .Image "rabbitmq rabbitmq:* */rabbitmq */rabbitmq:*") }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}

  - id: "redis"
    match: '{{ or (eq .PrivatePort "6379") (match "sp" .Image "redis redis:* */redis */redis:*") }}'
    config_template: |
      name: docker_{{.Name}}
      address: redis://@{{.Address}}

  - id: "rethinkdb"
    match: '{{ and (eq .PrivatePort "28015") (match "sp" .Image "rethinkdb rethinkdb:* */rethinkdb */rethinkdb:*") }}'
    config_template: |
      name: docker_{{.Name}}
      address: {{.Address}}

  - id: "squid"
    match: '{{ match "sp" .Image "*/squid */squid:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}

  - id: "tengine"
    match: '{{ match "sp" .Image "*/tengine */tengine:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}/us

  - id: "tor"
    match: '{{ and (eq .PrivatePort "9051") (match "sp" .Image "*/tor */tor:*") }}'
    config_template: |
      name: docker_{{.Name}}
      address: {{.Address}}

  - id: "tomcat"
    match: '{{ match "sp" .Image "tomcat tomcat:* */tomcat */tomcat:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}

  - id: "typesense"
    match: '{{ match "sp" .Image "typesense/typesense typesense/typesense:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}
      api_key: {{ trimPrefix "--api-key=" (regexFind "--api-key=[^ ]+" .Command) -}}

  - id: "varnish"
    match: '{{ match "sp" .Image "varnish varnish:*" }}'
    config_template: |
      name: docker_{{.Name}}
      docker_container: {{.Name}}

  - id: "vernemq"
    match: '{{ match "sp" .Image "*/vernemq */vernemq:*" }}'
    config_template: |
      name: docker_{{.Name}}
      url: http://{{.Address}}/metrics

  - id: "zookeeper"
    match: '{{ or (eq .PrivatePort "2181") (match "sp" .Image "*/zookeeper */zookeeper:*") }}'
    config_template: |
      name: docker_{{.Name}}
      address: {{.Address}}
