Example #1
0
# (C) Datadog, Inc. 2018-present
# All rights reserved
# Licensed under Simplified BSD License (see LICENSE)
import os
import socket

from datadog_checks.dev import get_docker_hostname
from datadog_checks.kafka_consumer.legacy_0_10_2 import LegacyKafkaCheck_0_10_2

HERE = os.path.dirname(os.path.abspath(__file__))
HOST = get_docker_hostname()
HOST_IP = socket.gethostbyname(HOST)
KAFKA_CONNECT_STR = '{}:9092'.format(HOST_IP)
ZK_CONNECT_STR = '{}:2181'.format(HOST)
TOPICS = ['marvel', 'dc']
PARTITIONS = [0, 1]


def is_supported(flavor):
    """
    Returns whether the current CI configuration is supported
    """
    if not os.environ.get('KAFKA_VERSION'):
        return False

    if flavor != os.environ.get('KAFKA_OFFSETS_STORAGE'):
        return False

    return True

Example #2
0
import os

import pytest

from datadog_checks.dev import docker_run, get_docker_hostname, get_here

URL = "http://{}:8000".format(get_docker_hostname())
INSTANCE = {"url": URL, "clusters": "local"}


@pytest.fixture(scope="session")
def dd_environment():
    compose_file = os.path.join(get_here(), "docker-compose.yaml")

    with docker_run(compose_file, endpoints=[URL]):
        yield INSTANCE


@pytest.fixture
def instance():
    return INSTANCE.copy()
Example #3
0
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os

from datadog_checks.dev import get_docker_hostname, get_here

HERE = get_here()
FIXTURE_DIR = os.path.join(HERE, 'fixtures')
CHECK_NAME = 'mesos_slave'
URL = 'http://{}:5051'.format(get_docker_hostname())

INSTANCE = {'url': URL, 'tasks': ['hello'], 'tags': ['instance:mytag1']}

BAD_INSTANCE = {'url': 'http://localhost:9999', 'tasks': ['hello']}
Example #4
0
# (C) Datadog, Inc. 2018-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

import os

from datadog_checks.dev import get_docker_hostname
from datadog_checks.yarn.yarn import YARN_APPS_PATH, YARN_CLUSTER_METRICS_PATH, YARN_NODES_PATH, YARN_SCHEDULER_PATH

HERE = os.path.dirname(os.path.abspath(__file__))

# IDs
CLUSTER_NAME = 'SparkCluster'

# Resource manager URI
RM_ADDRESS = 'http://{}:8088'.format(get_docker_hostname())

# Service URLs
YARN_CLUSTER_METRICS_URL = '{}{}'.format(RM_ADDRESS, YARN_CLUSTER_METRICS_PATH)
YARN_APPS_URL = '{}{}'.format(RM_ADDRESS, YARN_APPS_PATH)
YARN_NODES_URL = '{}{}'.format(RM_ADDRESS, YARN_NODES_PATH)
YARN_SCHEDULER_URL = '{}{}'.format(RM_ADDRESS, YARN_SCHEDULER_PATH)

CUSTOM_TAGS = ['optional:tag1']

TEST_USERNAME = '******'
TEST_PASSWORD = '******'

INSTANCE_INTEGRATION = {
    "resourcemanager_uri": RM_ADDRESS,
    "cluster_name": CLUSTER_NAME,
import os

import pytest
import requests

from datadog_checks.dev import docker_run, get_docker_hostname, get_here
from datadog_checks.dev.conditions import WaitFor

DOCKER_DIR = os.path.join(get_here(), 'docker')
INSTANCE = {
    'host': get_docker_hostname(),
    'port': 2004,
    'neo4j_version': os.environ['NEO4J_VERSION'],
}


def ensure_prometheus_endpoint_is_accessable():
    instance = INSTANCE
    url = 'http://{}:{}/metrics'.format(instance.get('host'),
                                        instance.get('port'))
    response = requests.get(url)
    response.raise_for_status()


@pytest.fixture(scope='session')
def dd_environment():
    instance = INSTANCE
    image = os.environ.get("NEO4J_IMAGE",
                           f"neo4j:{os.environ['NEO4J_VERSION']}-enterprise")
    with docker_run(
            os.path.join(DOCKER_DIR, 'docker-compose.yaml'),
Example #6
0
import os

import pytest

from datadog_checks.dev import docker_run, get_docker_hostname, get_here

URL = 'http://{}:8000/opcache-dd-handler.php'.format(get_docker_hostname())
INSTANCE = {'url': URL}


@pytest.fixture(scope='session')
def dd_environment():
    compose_file = os.path.join(get_here(), 'docker-compose.yml')

    with docker_run(compose_file, endpoints=[URL]):
        yield INSTANCE


@pytest.fixture
def instance():
    return INSTANCE.copy()
Example #7
0
def test_service_check(aggregator, eventstore_server):
    init_config = {
        'metric_definitions': [
            {
                "json_path": "proc.mem",
                "json_type": "int",
                "metric_name": "eventstore.proc.mem",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.cpu",
                "json_type": "float",
                "metric_name": "eventstore.proc.cpu",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.cpuScaled",
                "json_type": "float",
                "metric_name": "eventstore.proc.cpu_scaled",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.threadsCount",
                "json_type": "int",
                "metric_name": "eventstore.proc.threads",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.contentionsRate",
                "json_type": "float",
                "metric_name": "eventstore.proc.contentions_rate",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.thrownExceptionsRate",
                "json_type": "float",
                "metric_name": "eventstore.proc.thrown_exceptions_rate",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.diskIo.readBytes",
                "json_type": "int",
                "metric_name": "eventstore.proc.disk.read_bytes",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.diskIo.writtenBytes",
                "json_type": "int",
                "metric_name": "eventstore.proc.disk.write_bytes",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.diskIo.readOps",
                "json_type": "int",
                "metric_name": "eventstore.proc.disk.read_ops",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.diskIo.writeOps",
                "json_type": "int",
                "metric_name": "eventstore.proc.disk.write_ops",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.connections",
                "json_type": "int",
                "metric_name": "eventstore.tcp.connections",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.receivingSpeed",
                "json_type": "float",
                "metric_name": "eventstore.tcp.receiving_speed",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.sendingSpeed",
                "json_type": "float",
                "metric_name": "eventstore.tcp.sending_speed",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.inSend",
                "json_type": "int",
                "metric_name": "eventstore.tcp.in_send",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.measureTime",
                "json_type": "datetime",
                "metric_name": "eventstore.tcp.measure_time",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.pendingReceived",
                "json_type": "int",
                "metric_name": "eventstore.tcp.pending_received",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.pendingSend",
                "json_type": "int",
                "metric_name": "eventstore.tcp.pending_send",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.receivedBytesSinceLastRun",
                "json_type": "int",
                "metric_name": "eventstore.tcp.received_bytes.since_last_run",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.receivedBytesTotal",
                "json_type": "int",
                "metric_name": "eventstore.tcp.received_bytes.total",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.sentBytesSinceLastRun",
                "json_type": "int",
                "metric_name": "eventstore.tcp.sent_bytes.since_last_run",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.tcp.sentBytesTotal",
                "json_type": "int",
                "metric_name": "eventstore.tcp.sent_bytes.total",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.allocationSpeed",
                "json_type": "float",
                "metric_name": "eventstore.gc.allocation_speed",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.gen0ItemsCount",
                "json_type": "float",
                "metric_name": "eventstore.gc.items_count.gen0",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.gen0Size",
                "json_type": "float",
                "metric_name": "eventstore.gc.size.gen0",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.gen1ItemsCount",
                "json_type": "float",
                "metric_name": "eventstore.gc.items_count.gen1",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.gen1Size",
                "json_type": "float",
                "metric_name": "eventstore.gc.size.gen1",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.gen2ItemsCount",
                "json_type": "float",
                "metric_name": "eventstore.gc.items_count.gen2",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.gen2Size",
                "json_type": "float",
                "metric_name": "eventstore.gc.size.gen2",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.largeHeapSize",
                "json_type": "int",
                "metric_name": "eventstore.gc.large_heap_size",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.timeInGc",
                "json_type": "float",
                "metric_name": "eventstore.gc.time_in_gc",
                "metric_type": "gauge"
            },
            {
                "json_path": "proc.gc.totalBytesInHeaps",
                "json_type": "int",
                "metric_name": "eventstore.gc.total_bytes_in_heaps",
                "metric_type": "gauge"
            },
            {
                "json_path": "sys.cpu",
                "json_type": "float",
                "metric_name": "eventstore.sys.cpu",
                "metric_type": "gauge"
            },
            {
                "json_path": "sys.freeMem",
                "json_type": "int",
                "metric_name": "eventstore.sys.free_mem",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.queue.*.avgItemsPerSecond",
                "json_type": "int",
                "metric_name": "eventstore.es.queue.avg_items_per_second",
                "metric_type": "histogram"
            },
            {
                "json_path": "es.queue.*.avgProcessingTime",
                "json_type": "float",
                "metric_name": "eventstore.es.queue.avg_processing_time",
                "metric_type": "histogram"
            },
            {
                "json_path": "es.queue.*.currentIdleTime",
                "json_type": "datetime",
                "metric_name": "eventstore.es.queue.current_idle_time",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.queue.*.currentItemProcessingTime",
                "json_type": "datetime",
                "metric_name": "eventstore.es.queue.current_processing_time",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.queue.*.idleTimePercent",
                "json_type": "float",
                "metric_name": "eventstore.es.queue.idle_time_percent",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.queue.*.length",
                "json_type": "int",
                "metric_name": "eventstore.es.queue.length",
                "metric_type": "histogram"
            },
            {
                "json_path": "es.queue.*.lengthCurrentTryPeak",
                "json_type": "int",
                "metric_name": "eventstore.es.queue.length_current_try_peak",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.queue.*.lengthLifetimePeak",
                "json_type": "int",
                "metric_name": "eventstore.es.queue.length_lifetime_peak",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.queue.*.totalItemsProcessed",
                "json_type": "int",
                "metric_name": "eventstore.es.queue.total_items_processed",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.writer.lastFlushSize",
                "json_type": "int",
                "metric_name": "eventstore.es.writer.flush_size.last",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.writer.lastFlushDelayMs",
                "json_type": "float",
                "metric_name": "eventstore.es.writer.flush_delay_ms.last",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.writer.meanFlushSize",
                "json_type": "int",
                "metric_name": "eventstore.es.writer.flush_size.mean",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.writer.meanFlushDelayMs",
                "json_type": "float",
                "metric_name": "eventstore.es.writer.flush_delay_ms.mean",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.writer.maxFlushSize",
                "json_type": "int",
                "metric_name": "eventstore.es.writer.flush_size.max",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.writer.maxFlushDelayMs",
                "json_type": "float",
                "metric_name": "eventstore.es.writer.flush_delay_ms.max",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.writer.queuedFlushMessages",
                "json_type": "int",
                "metric_name": "eventstore.es.writer.queued_flush_messages",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.readIndex.cachedRecord",
                "json_type": "int",
                "metric_name": "eventstore.es.read_index.cached_record",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.readIndex.notCachedRecord",
                "json_type": "int",
                "metric_name": "eventstore.es.read_index.not_cached_record",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.readIndex.cachedStreamInfo",
                "json_type": "int",
                "metric_name": "eventstore.es.read_index.cached_stream_info",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.readIndex.notCachedStreamInfo",
                "json_type": "int",
                "metric_name": "eventstore.es.read_index.not_cached_stream_info",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.readIndex.cachedTransInfo",
                "json_type": "int",
                "metric_name": "eventstore.es.read_index.cached_trans_info",
                "metric_type": "gauge"
            },
            {
                "json_path": "es.readIndex.notCachedTransInfo",
                "json_type": "int",
                "metric_name": "eventstore.es.read_index.not_cached_trans_info",
                "metric_type": "gauge"
            }
        ]
    }

    c = EventStoreCheck('eventstore', init_config, {}, None)

    # the check should send OK
    instance = {
        'default_timeout': 5,
        'tag_by_url': True,
        'url': 'http://{}:2113/stats'.format(get_docker_hostname()),
        'name': 'testInstance',
        'json_path': [
            '*',
            '*.*',
            '*.*.*',
            '*.*.*.*'
        ]
    }
    c.check(instance)
    for metric in init_config['metric_definitions']:
        aggregator.assert_metric(metric['metric_name'], tags=[])

    i = 1
    for m in aggregator.not_asserted():
        print(m)
        print('\r')
        print(i)
        i = i + 1
    # Assert coverage for this check on this instance
    aggregator.assert_all_metrics_covered()
Example #8
0
BACKENDS_METRICS = ('proxysql.backends.count',)

QUERY_RULES_TAGS_METRICS = ('proxysql.query_rules.rule_hits',)


ALL_METRICS = (
    GLOBAL_METRICS
    + MEMORY_METRICS
    + COMMANDS_COUNTERS_METRICS
    + CONNECTION_POOL_METRICS
    + USER_TAGS_METRICS
    + QUERY_RULES_TAGS_METRICS
)

DOCKER_HOST = get_docker_hostname()
MYSQL_PORT = 6612
PROXY_PORT = 6033
PROXY_ADMIN_PORT = 6032
MYSQL_USER = '******'
MYSQL_PASS = '******'
PROXY_ADMIN_USER = '******'
PROXY_ADMIN_PASS = '******'
PROXY_STATS_USER = '******'
PROXY_STATS_PASS = '******'
MYSQL_DATABASE = 'test'
PROXY_MAIN_DATABASE = 'main'
PROXYSQL_VERSION = os.environ['PROXYSQL_VERSION']

BASIC_INSTANCE = {
    'host': DOCKER_HOST,
# (C) Datadog, Inc. 2019
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os

from datadog_checks.dev import get_docker_hostname, get_here

HERE = get_here()
COMPOSE_FILE = os.path.join(HERE, 'docker', 'docker-compose.yaml')
SERVER = get_docker_hostname()
PORT = 39017

CONFIG = {
    'server': SERVER,
    'port': PORT,
    'username': '******',
    'password': '******'
}
ADMIN_CONFIG = {
    'server': SERVER,
    'port': PORT,
    'username': '******',
    'password': '******'
}

# TODO: Remove
E2E_METADATA = {'start_commands': ['pip install pyhdb']}
import os

import pytest

from datadog_checks.dev import docker_run, get_docker_hostname, get_here

CONTROL_URL = 'http://{}:19293/stats?token=12345'.format(get_docker_hostname())
INSTANCE = {'control_url': CONTROL_URL}
TEST_SERVER_URL = 'http://{}:30001/'.format(get_docker_hostname())


@pytest.fixture(scope='session')
def dd_environment():
    compose_file = os.path.join(get_here(), 'docker', 'docker-compose.yml')

    with docker_run(compose_file, endpoints=[CONTROL_URL]):
        yield INSTANCE


@pytest.fixture
def instance():
    return INSTANCE.copy()


@pytest.fixture
def test_server():
    return TEST_SERVER_URL