procmatch

package
v0.0.0-...-dca2ff9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

procmatch

Procmatch is a library that provides a way to extract datadog-integrations from command lines by using a catalog.

Getting Started

Installing

To install the package: go get -u github.com/DataDog/datadog-agent/pkg/procmatch

Usage:

package main

import (
	"fmt"

	"github.com/DataDog/datadog-agent/pkg/procmatch"
)

func main() {
    matcher, err := procmatch.NewDefault()
    if err != nil {
        // Handle the error
    }

    cmd := "java org.elasticsearch.bootstrap.elasticsearch"
    fmt.Printf("Integration: %s\n", matcher.Match(cmd).Name)
    // Outputs:
    // Integration: elastic
}

The default catalog is available here

Adding a new integration's signature

To add a new integration signature, you will first have to add it inside its manifest.json file in the datadog integration-core repo under the process_signatures field.

After that create a PR on the datadog integration-core repo to commit your change.

Then you can regenerate the default catalog to get the new signature here (see section below to regenerate the catalog)

For testing purposes you can also modify the generated file /default_catalog.go.

Generate a new catalog

The catalog is generated here, you will first need to clone the datadog integration-core repo.

Then you can run INTEGRATIONS_CORE_DIR=<path_to_integration_repo> go generate ./... or INTEGRATIONS_CORE_DIR=<path_to_integration_repo> go generate ./pkg/procmatch if you're at the repo root.

The generation script reads process signatures from the manifest.json files.

Adding tests for an integration

To add a new test for a given integration you can add an entry inside the test cases in TestMatchIntegration under graph_matcher_test.go, it will try to match an integration on your provided command line by using the default catalog.

Running the tests

To run the tests simply do: go test ./...

There are also benchmarks included, to run them you can do: go test -bench=.

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Integration

type Integration struct {
	MetricPrefix string // Metric prefix of the integration
	Name         string // Name of the integration
	DisplayName  string // DisplayName of the integration
}

Integration represents an integration

type IntegrationCatalog

type IntegrationCatalog []IntegrationEntry

IntegrationCatalog represents a list of Integrations

var DefaultCatalog IntegrationCatalog = IntegrationCatalog{
	IntegrationEntry{
		DisplayName:  "ActiveMQ",
		MetricPrefix: "activemq.",
		Name:         "activemq",
		Signatures: []string{
			"activemq",
		},
	},
	IntegrationEntry{
		DisplayName:  "Apache",
		MetricPrefix: "apache.",
		Name:         "Apache",
		Signatures: []string{
			"httpd",
			"apache",
			"apache2",
		},
	},
	IntegrationEntry{
		DisplayName:  "Cassandra",
		MetricPrefix: "cassandra.",
		Name:         "cassandra",
		Signatures: []string{
			"java org.apache.cassandra.service.CassandraDaemon",
		},
	},
	IntegrationEntry{
		DisplayName:  "Ceph",
		MetricPrefix: "ceph.",
		Name:         "ceph",
		Signatures: []string{
			"ceph-mon",
			"ceph-mgr",
			"ceph-osd",
		},
	},
	IntegrationEntry{
		DisplayName:  "Consul",
		MetricPrefix: "consul.",
		Name:         "consul",
		Signatures: []string{
			"consul agent",
			"consul_agent",
			"consul-agent",
		},
	},
	IntegrationEntry{
		DisplayName:  "CouchDB",
		MetricPrefix: "couch.",
		Name:         "couch",
		Signatures: []string{
			"couchjs",
		},
	},
	IntegrationEntry{
		DisplayName:  "Couchbase",
		MetricPrefix: "couchbase.",
		Name:         "couchbase",
		Signatures: []string{
			"beam.smp couchbase",
		},
	},
	IntegrationEntry{
		DisplayName:  "Docker",
		MetricPrefix: "docker.",
		Name:         "docker_daemon",
		Signatures: []string{
			"dockerd",
			"docker-containerd",
			"docker run",
			"docker daemon",
			"docker-containerd-shim",
		},
	},
	IntegrationEntry{
		DisplayName:  "Elasticsearch",
		MetricPrefix: "elasticsearch.",
		Name:         "elastic",
		Signatures: []string{
			"java org.elasticsearch.bootstrap.Elasticsearch",
		},
	},
	IntegrationEntry{
		DisplayName:  "etcd",
		MetricPrefix: "etcd.",
		Name:         "etcd",
		Signatures: []string{
			"etcd",
		},
	},
	IntegrationEntry{
		DisplayName:  "fluentd",
		MetricPrefix: "fluentd.",
		Name:         "fluentd",
		Signatures: []string{
			"td-agent",
			"fluentd",
			"ruby td-agent",
		},
	},
	IntegrationEntry{
		DisplayName:  "Gearman",
		MetricPrefix: "gearmand.",
		Name:         "gearmand",
		Signatures: []string{
			"gearmand",
			"gearman",
		},
	},
	IntegrationEntry{
		DisplayName:  "Gunicorn",
		MetricPrefix: "gunicorn.",
		Name:         "gunicorn",
		Signatures: []string{
			"gunicorn: master",
		},
	},
	IntegrationEntry{
		DisplayName:  "HAProxy",
		MetricPrefix: "haproxy.",
		Name:         "haproxy",
		Signatures: []string{
			"haproxy",
			"haproxy-master",
			"haproxy-controller",
		},
	},
	IntegrationEntry{
		DisplayName:  "Kafka",
		MetricPrefix: "kafka.",
		Name:         "kafka",
		Signatures: []string{
			"java kafka.kafka",
		},
	},
	IntegrationEntry{
		DisplayName:  "Kong",
		MetricPrefix: "kong.",
		Name:         "kong",
		Signatures: []string{
			"kong start",
		},
	},
	IntegrationEntry{
		DisplayName:  "Kyoto Tycoon",
		MetricPrefix: "kyototycoon.",
		Name:         "kyototycoon",
		Signatures: []string{
			"ktserver",
		},
	},
	IntegrationEntry{
		DisplayName:  "Lighttpd",
		MetricPrefix: "lighttpd.",
		Name:         "lighttpd",
		Signatures: []string{
			"lighttpd",
		},
	},
	IntegrationEntry{
		DisplayName:  "Marathon",
		MetricPrefix: "marathon.",
		Name:         "marathon",
		Signatures: []string{
			"start --master mesos marathon",
		},
	},
	IntegrationEntry{
		DisplayName:  "Memcached",
		MetricPrefix: "memcache.",
		Name:         "mcache",
		Signatures: []string{
			"memcached",
		},
	},
	IntegrationEntry{
		DisplayName:  "Mesos Master",
		MetricPrefix: "mesos.",
		Name:         "mesos_master",
		Signatures: []string{
			"mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos",
			"mesos-agent.sh --master --work_dir=/var/lib/mesos",
		},
	},
	IntegrationEntry{
		DisplayName:  "MongoDB",
		MetricPrefix: "mongodb.",
		Name:         "mongo",
		Signatures: []string{
			"mongod",
		},
	},
	IntegrationEntry{
		DisplayName:  "MySQL",
		MetricPrefix: "mysql.",
		Name:         "MySQL",
		Signatures: []string{
			"mysqld",
		},
	},
	IntegrationEntry{
		DisplayName:  "Nagios",
		MetricPrefix: "nagios.",
		Name:         "nagios",
		Signatures: []string{
			"nagios",
		},
	},
	IntegrationEntry{
		DisplayName:  "Nginx",
		MetricPrefix: "nginx.",
		Name:         "nginx",
		Signatures: []string{
			"nginx: master process",
		},
	},
	IntegrationEntry{
		DisplayName:  "OpenStack",
		MetricPrefix: "openstack.",
		Name:         "openstack",
		Signatures: []string{
			"stack.sh",
		},
	},
	IntegrationEntry{
		DisplayName:  "PGBouncer",
		MetricPrefix: "pgbouncer.",
		Name:         "pgbouncer",
		Signatures: []string{
			"pgbouncer",
		},
	},
	IntegrationEntry{
		DisplayName:  "PHP-FPM",
		MetricPrefix: "php_fpm.",
		Name:         "php_fpm",
		Signatures: []string{
			"php-fpm",
			"php7.0-fpm",
			"php7.0-fpm start",
			"service php-fpm",
			"php7.0-fpm restart",
			"restart php-fpm",
			"systemctl restart php-fpm.service",
			"php7.0-fpm.service",
		},
	},
	IntegrationEntry{
		DisplayName:  "Postfix",
		MetricPrefix: "postfix.",
		Name:         "postfix",
		Signatures: []string{
			"postfix start",
			"sendmail -bd",
		},
	},
	IntegrationEntry{
		DisplayName:  "Postgres",
		MetricPrefix: "postgresql.",
		Name:         "postgres",
		Signatures: []string{
			"postgres -D",
			"pg_ctl start -l logfile",
			"postgres -c &#39;pg_ctl start -D -l",
		},
	},
	IntegrationEntry{
		DisplayName:  "PowerDNS Recursor",
		MetricPrefix: "powerdns.",
		Name:         "powerdns_recursor",
		Signatures: []string{
			"pdns_server",
			"systemctl start pdns@",
		},
	},
	IntegrationEntry{
		DisplayName:  "RabbitMQ",
		MetricPrefix: "rabbitmq.",
		Name:         "rabbitmq",
		Signatures: []string{
			"rabbitmq",
		},
	},
	IntegrationEntry{
		DisplayName:  "Redis",
		MetricPrefix: "redis.",
		Name:         "redisdb",
		Signatures: []string{
			"redis-server",
		},
	},
	IntegrationEntry{
		DisplayName:  "Riak CS",
		MetricPrefix: "riakcs.",
		Name:         "riakcs",
		Signatures: []string{
			"riak-cs start",
		},
	},
	IntegrationEntry{
		DisplayName:  "Solr",
		MetricPrefix: "solr.",
		Name:         "solr",
		Signatures: []string{
			"solr start",
		},
	},
	IntegrationEntry{
		DisplayName:  "SSH",
		MetricPrefix: "ssh.",
		Name:         "ssh_check",
		Signatures: []string{
			"ssh",
			"sftp",
			"sshd",
			"sshd:",
		},
	},
	IntegrationEntry{
		DisplayName:  "Supervisord",
		MetricPrefix: "supervisord.",
		Name:         "supervisord",
		Signatures: []string{
			"python supervisord",
			"supervisord",
		},
	},
	IntegrationEntry{
		DisplayName:  "Teamcity",
		MetricPrefix: "teamcity.",
		Name:         "teamcity",
		Signatures: []string{
			"teamcity-server.sh",
			"teamcity-server",
		},
	},
	IntegrationEntry{
		DisplayName:  "TokuMX",
		MetricPrefix: "tokumx.",
		Name:         "tokumx",
		Signatures: []string{
			"mongod --config /etc/tokumx.conf",
		},
	},
	IntegrationEntry{
		DisplayName:  "Tomcat",
		MetricPrefix: "tomcat.",
		Name:         "tomcat",
		Signatures: []string{
			"java tomcat",
		},
	},
	IntegrationEntry{
		DisplayName:  "Varnish",
		MetricPrefix: "varnish.",
		Name:         "varnish",
		Signatures: []string{
			"service varnish start",
		},
	},
	IntegrationEntry{
		DisplayName:  "ZooKeeper",
		MetricPrefix: "zookeeper.",
		Name:         "zk",
		Signatures: []string{
			"zkServer.sh start",
			"java zoo.cfg",
		},
	},
}

type IntegrationEntry

type IntegrationEntry struct {
	MetricPrefix string   // Metric prefix of the integration
	Name         string   // Name of the integration
	DisplayName  string   // DisplayName of the integration
	Signatures   []string // Signatures of the integration's command line processes
}

IntegrationEntry represents an integration entry in the catalog

type Matcher

type Matcher interface {
	Match(cmdline string) Integration // Return the matched integration
}

Matcher interface implements the Match method that takes a command line string and returns a potential integration for this command line string

func NewDefault

func NewDefault() (Matcher, error)

NewDefault returns the default matcher (graph one) built with the default catalog

func NewMatcher

func NewMatcher(catalog IntegrationCatalog) (Matcher, error)

NewMatcher builds a graph matcher from an integration catalog

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL