# ========================================================
# Definition of autodiscovery patterns
# ========================================================

# The top level element identifies the app type.
# The value of this element is used by AA to correctly
# setup the corresponding agent. Then we have a number
# of attributes that determines whether certain app is
# discovered as such. Firstly, the `process` accepts a
# regular expression pattern to identify process's image
# name that originated the event and is susceptible for
# classification.
# Then, we have `args` that represents the regular expression
# used to match the tokens from process's command line. The
# sequence of well-known ports is also used as an advice to
# autodisco machinery that specific service could expose these
# ports. The Infra agent also sends requests to these ports
# in order to get additional meta info.


# Finally, `labels` attribute provides custom key-value pairs
# that are attached as container labels/env vars. The naming
# of some of them might be specific to AA framework and thus
# are used by itself.

# You can use any valid go template (https://golang.org/pkg/text/template/)
# construct inside yaml file. You can access command line args
# or discovered ports like this:
#
# labels:
#   cmdline: "{{ .Args}}"
#
# For instance to get the container id or container name you
# would use the following go template action. Please note that built-in `isset`
# function is used to ensure container details are present since some
# apps can be discovered in the VM or baremetal host and thus lack container
# meta.
#
# labels:
#    container.name: '{{if isset .ContainerInfo "Name"}}{{ .ContainerInfo.Name }}{{end}}'
#    container.id:  '{{if isset .ContainerInfo "ID"}}{{ .ContainerInfo.ID }}{{end}}'

# You can also query app meta info through `Meta` field. For example, to get
# the version of nginx server use '{{if isset .Meta "Version"}}{{ .Meta.Version }}{{end}}'
# in `labels` section.

# To pull secrets that are attached to containers use '{{index .Secrets "SECRET_NAME"}}'

cassandra:
  process: java
  args: .*org.apache.cassandra.service.CassandraDaemon.*
  ports:
    - 7199
    - 7000
    - 7001
    - 9160
    - 9042

clickhouse:
  process: clickhouse-.*
  args: clickhouse-server --config=.*
  ports:
    - 8123
    - 9000
    - 9009
  labels:
    SPM_MONITOR_CLICKHOUSE_DB_HOST_PORT: "{{ .IP }}:8123"
    SPM_MONITOR_CLICKHOUSE_DB_USER:
    SPM_MONITOR_CLICKHOUSE_DB_PASSWORD:

es:
  process: java
  args: .*org.elasticsearch.bootstrap.Elasticsearch.*
  ports:
    - 9200
    - 9300
    - 9201
    - 9202
    - 9301
    - 9302

haproxy:
  process: haproxy
  args: .*haproxy.*haproxy.cfg.*-p

httpd:
  process: httpd
  args: httpd-*D*
  ports:
    - 80
    - 443
    - 8080
    - 8443

kafka:
  process: java
  args: kafka.Kafka .*server\.properties
  ports:
    - 9092

mongodb:
  process: mongod|listener|conn\d+
  args: mongod.*|listener|conn\d+
  ports:
    - 27017

mysql:
  process: mysqld
  args: mysqld.*
  ports:
    - 3306

nginx:
  process: nginx
  args: "nginx: master process.*|nginx: worker process.*|nginx -g daemon off.*"
  ports:
    - 80
    - 443
    - 8080
    - 8443
  labels:
    container.name: '{{if isset .ContainerInfo "Name"}}{{ .ContainerInfo.Name }}{{end}}'
    container.id: '{{if isset .ContainerInfo "ID"}}{{ .ContainerInfo.ID }}{{end}}'
    version: '{{if isset .Meta "Version"}}{{ .Meta.Version }}{{end}}'

redis:
  process: redis-server
  args: redis-server .*
  ports:
    - 6379

solr:
  process: java
  args: .*-Dsolr.solr.home.*|.*-Dsolr.install.dir.*
  ports:
    - 8983
    - 7983

spark-master:
  process: java
  args: .*org.apache.spark.deploy.master.Master.*
  ports:
    - 7707
    - 4040

spark-worker:
  process: java
  args: .*org.apache.spark.deploy.worker.Worker.*
  ports:
    - 7707
    - 4040

spark-driver:
  process: java
  args: .*org.apache.spark.deploy.SparkSubmit.*--deploy-mode client.*|.*org.apache.spark.deploy.worker.DriverWrapper.*
  ports:
    - 7707
    - 4040

spark-executor:
  process: java
  args: .*org.apache.spark.executor.CoarseGrainedExecutorBackend.*
  ports:
    - 7707
    - 4040

storm-nimbus:
  process: java
  args: .*org.apache.storm.daemon.nimbus.*
  ports:
    - 6627
    - 6700
    - 6701
    - 6702
    - 6703

storm-supervisor:
  process: java
  args: .*org.apache.storm.daemon.supervisor.Supervisor.*
  ports:
    - 6627
    - 6700
    - 6701
    - 6702
    - 6703

storm-worker:
  process: java
  args: .*org.apache.storm.daemon.worker.*
  ports:
    - 6627
    - 6700
    - 6701
    - 6702
    - 6703

tomcat:
  process: java
  args: .*catalina.*org.apache.catalina.startup.Bootstrap.*
  ports:
    - 80
    - 443
    - 8080
    - 8443

zookeeper:
  process: java
  args: .*-Dzookeeper.log.dir.*|.*org.apache.zookeeper.server.quorum.QuorumPeerMain.*
  ports:
    - 2181
    - 2888
    - 3888