Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_docker_daemon: initial release #538

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions win_docker_daemon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CHANGELOG - win_docker_daemon

## [Unreleased]

## [0.0.1] - 2020-02-10
### Added
- Initial plugin check
- Unit tests
- manifests and assets per integration-extra best practice

10 changes: 10 additions & 0 deletions win_docker_daemon/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
graft datadog_checks
graft tests

include MANIFEST.in
include README.md
include requirements.in
include requirements-dev.txt
include manifest.json

global-exclude *.py[cod] __pycache__
99 changes: 99 additions & 0 deletions win_docker_daemon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Agent Check: win_docker_daemon

## Overview

This check monitors [win_docker_daemon][1] through the Datadog Agent. This integration targets gathering docker stats from the daemon api for Windows containers. The core docker integration uses the filesystem\cgroups to gather performance stats. This approach does not work with Windows. This integration attempts to create the same metrics as the docker integration. It currently targets:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This check monitors [win_docker_daemon][1] through the Datadog Agent. This integration targets gathering docker stats from the daemon api for Windows containers. The core docker integration uses the filesystem\cgroups to gather performance stats. This approach does not work with Windows. This integration attempts to create the same metrics as the docker integration. It currently targets:
This check monitors [win_docker_daemon][1] through the Datadog Agent. This integration targets gathering docker stats from the daemon api for Windows containers. The core docker integration uses the filesystem\cgroups to gather performance stats which is not applicable on Windows. This integration attempts to collect the same metrics as the docker integration. It currently targets:

We should add a link to the docker integration that is mentioned.

- events
- cpu
- memory
- network

This module borrows heavily from the old docker_daemon plugin.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link missing


### Installation

To install the win_docker_daemon check on your host:

1. Install the [developer toolkit](https://docs.datadoghq.com/developers/integrations/new_check_howto/#developer-toolkit) on any machine.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link should be set as reference in the whole README.md

2. Run `ddev release build win_docker_daemon` to build the package.
3. [Download the Datadog Agent](https://app.datadoghq.com/account/settings#agent).
4. Upload the build artifact to any host with an Agent andrun `datadog-agent integration install -w path/to/win_docker_daemon/dist/<ARTIFACT_NAME>.whl`.

### Configuration

1. Edit the `win_docker_daemon.d/conf.yaml` file, in the `conf.d/` folder at the root of your Agent's configuration directory to start collecting your win_docker_daemon performance data. See the [sample win_docker_daemon.d/conf.yaml][3] for all available configuration options.

2. [Restart the Agent][4].

### Validation

[Run the Agent's status subcommand][5] and look for `win_docker_daemon` under the Checks section.

## Data Collected

### Metrics
| name | type | description |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to inline the metrics in the README here, just adding:

See [metadata.csv](<LINK_TO_METADATA.CSV_FILE>) for a full list of provided metrics by this integration.

will inline automatically the metrics table in the public Datadog documentation.

|------|-------|-------------|
| docker.containers.stopped | gauge | |
| docker.containers.stopped.total | gauge | |
| docker.containers.running | gauge | |
| docker.containers.running.total | gauge | |
| docker.cpu.usage | gauge | |
| docker.cpu.usage.95percentile | gauge | 95th percentile of docker.cpu.usage|
| docker.cpu.usage.avg | gauge | Average value of docker.cpu.usage|
| docker.cpu.usage.count | rate | The rate that the value of docker.cpu.usage was sampled|
| docker.cpu.usage.max | gauge | Max value of docker.cpu.usage |
| docker.cpu.usage.median | gauge | Median value of docker.cpu.usage|
| docker.cpu.system | gauge |
| docker.cpu.system.95percentile | gauge | 95th percentile of docker.cpu.system
| docker.cpu.system.avg | gauge | Average value of docker.cpu.system
| docker.cpu.system.count | rate | The rate that the value of docker.cpu.system was sampled
| docker.cpu.system.max | gauge | Max value of docker.cpu.system
| docker.cpu.system.median | gauge |
| docker.cpu.user | gauge |
| docker.cpu.user.95percentile | gauge | 95th percentile of docker.cpu.user
| docker.cpu.user.avg | gauge | Average value of docker.cpu.user
| docker.cpu.user.count | rate | The rate that the value of docker.cpu.user was sampled
| docker.cpu.user.max | gauge | Max value of docker.cpu.user
| docker.cpu.user.median | gauge | Median value of docker.cpu.user
| docker.mem.commit | gauge |
| docker.mem.commit.95percentile | gauge | 95th percentile of docker.mem.commit
| docker.mem.commit.avg | gauge | Average value of docker.mem.commit
| docker.mem.commit.count | rate | The rate that the value of docker.mem.commit was sampled
| docker.mem.commit.max | gauge | Max value of docker.mem.commit
| docker.mem.commit.median | gauge | Median value of docker.mem.commit
| docker.mem.rss' | gauge |
| docker.mem.rss.95percentile | gauge | 95th percentile of docker.mem.ws
| docker.mem.rss.avg | gauge | Average value of docker.mem.ws
| docker.mem.rss.count | rate | The rate that the value of docker.mem.ws was sampled
| docker.mem.rss.max | gauge | Max value of docker.mem.ws
| docker.mem.rss.median | gauge | Median value of docker.mem.ws
| docker.net.bytes_rcvd' | rate | Byte rate being received
| docker.net.bytes_sent | rate | Byte rate being sent


### Service Checks
- docker.exit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service check description is missing



### Events
- Die
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Event description is missing

- Create
- Start


## Troubleshooting

Need help? Contact [Datadog support][6].

[1]: **LINK_TO_INTEGRATION_SITE**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link missing

[2]: https://docs.datadoghq.com/agent/autodiscovery/integrations
[3]: https://github.com/DataDog/integrations-core/blob/master/win_docker_daemon/datadog_checks/win_docker_daemon/data/conf.yaml.example
[4]: https://docs.datadoghq.com/agent/guide/agent-commands/?tab=agentv6#start-stop-and-restart-the-agent
[5]: https://docs.datadoghq.com/agent/guide/agent-commands/?tab=agentv6#agent-status-and-information
[6]: https://docs.datadoghq.com/help


### TODO's
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed in the final version of the README.md

- [X] unit tests
- [ ] integration tests
Empty file added win_docker_daemon/__init__.py
Empty file.
Binary file added win_docker_daemon/assets/logos/avatars-bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added win_docker_daemon/assets/logos/saas_logos-bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions win_docker_daemon/assets/service_checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"agent_version": "0.0.1",
"integration": "win_docker_daemon",
"check": "docker.exit",
"statuses": ["ok", "critical"],
"groups": [],
"name": "Exit code check",
"description": "Looks at the exit code of an exited docker container. Return CRITICAL if non-zero and OK otherwise."
hithwen marked this conversation as resolved.
Show resolved Hide resolved
}
]
3 changes: 3 additions & 0 deletions win_docker_daemon/datadog_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
print(__path__)
hithwen marked this conversation as resolved.
Show resolved Hide resolved
print(__name__)
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.0.1'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .__about__ import __version__
from .win_docker_daemon import WinDockerDaemonCheck

__all__ = ['__version__', 'WinDockerDaemonCheck']
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
init_config:

instances:
## @param url - string - required
## Base docker daemon api instance.
#
- url : http://127.0.0.1:2375

## @param min_collection_interval - int - required
## Required for Agent 6 checks
#
min_collection_interval: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import json
import os
from datetime import datetime

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


class APIMockClient:
def containers(self):
all_containers = {}
with open(os.path.join(HERE, 'fixtures', 'all_containers.json'), 'r') as f:
all_containers = json.load(f)

return all_containers

def stats(self, container_id):
stats = {}
with open(os.path.join(HERE, 'fixtures', 'stats.json'), 'r') as f:
stats = json.load(f)
return stats[container_id]

def events(
self,
since=0,
until=int((datetime.utcnow() - datetime.utcfromtimestamp(0)).total_seconds()),
filters=json.dumps({"type": ["container"]}),
):
all_events = []
with open(os.path.join(HERE, 'fixtures', 'events.json'), 'r') as f:
all_events = json.load(f)

return all_events
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


@pytest.fixture(scope='session')
def dd_environment():
yield


@pytest.fixture
def instance():
return {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
[{
"Id": "61ee07eac005409c8e047d7721d44beae75fa81a673df70726fb7bcabf20485a",
"Names": ["/my-running-image.kvtu1ib57uofp7ompwldwtdxt"],
"Image": "my-running-image:latest",
"ImageID": "sha256:2d4405a3daac8959207b103c843bfb2987254b8d3b176db24666d4d3b648100f",
"Command": "C:/entrypoint.bat",
"Created": 1581025452,
"Ports": [],
"Labels": {
"com.docker.swarm.node.id": "x972iubw3f7s4h9a2s1y79ucc",
"com.docker.swarm.service.id": "jyx7cq6dx5qgvjlh6qng8oqhx",
"com.docker.swarm.service.name": "MyRunningImage",
"com.docker.swarm.task": "",
"com.docker.swarm.task.id": "kvtu1ib57uofp7ompwldwtdxt",
"com.docker.swarm.task.name": "MyRunningImage.2.kvtu1ib57uofp7ompwldwtdxt"
},
"State": "running",
"Status": "Up20hours",
"HostConfig": {
"NetworkMode": "default"
},
"NetworkSettings": {
"Networks": {
"ingress": {
"IPAMConfig": {
"IPv4Address": "10.255.46.35"
},
"Links": null,
"Aliases": null,
"NetworkID": "l426kv9m20yvsr9e0d8zdi0za",
"EndpointID": "c130f4035f0ce1200861c6b757f22cda91b1a7aa784bba622b811b062b67d5aa",
"Gateway": "",
"IPAddress": "10.255.46.35",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "00:15:5d:1b:41:e2",
"DriverOpts": null
}
}
},
"Mounts": []
}, {
"Id": "5dad097bc61a7ded78025be0d6dfc5434a9785df0dcfb04108f1857c1ca5f118",
"Names": ["/my-other-running-image.1.rsqdvl4j5ihnei2c6drjhqzz0"],
"Image": "my-other-running-image:1.1.0-alpha.136.136",
"ImageID": "sha256:2d4405a3daac8959207b103c843bfb2987254b8d3b176db24666d4d3b648100f",
"Command": "C:/entrypoint.bat",
"Created": 1581025439,
"Ports": [],
"Labels": {
"com.docker.swarm.node.id": "x972iubw3f7s4h9a2s1y79ucc",
"com.docker.swarm.service.id": "jyx7cq6dx5qgvjlh6qng8oqhx",
"com.docker.swarm.service.name": "MyOtherRunningImage",
"com.docker.swarm.task": "",
"com.docker.swarm.task.id": "rsqdvl4j5ihnei2c6drjhqzz0",
"com.docker.swarm.task.name": "MyOtherRunningImage.1.rsqdvl4j5ihnei2c6drjhqzz0"
},
"State": "running",
"Status": "Up20hours",
"HostConfig": {
"NetworkMode": "default"
},
"NetworkSettings": {
"Networks": {
"ingress": {
"IPAMConfig": {
"IPv4Address": "10.255.46.34"
},
"Links": null,
"Aliases": null,
"NetworkID": "l426kv9m20yvsr9e0d8zdi0za",
"EndpointID": "0afb45714531accba40be675c321f0040b09c8f85c822c43c000dae61218a937",
"Gateway": "",
"IPAddress": "10.255.46.34",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "00:15:5d:1b:45:0b",
"DriverOpts": null
}
}
},
"Mounts": []
}, {
"Id": "d985bf3e4750664c3b1e3a0d8587502b7e59d0a7ced108447ad510ed0714eceb",
"Names": ["/my-exited-image.2.yj9zptsznwfnq2qh1cdhlvh4i"],
"Image": "my-exited-image:1.1.0-alpha.1535.1535",
"ImageID": "sha256:b13905943bb884e6cc05f4f4c7f80ae715c6c87484ff1e8a5c79b716be386634",
"Command": "C:/entrypoint.bat",
"Created": 1580753163,
"Ports": [],
"Labels": {
"com.docker.swarm.node.id": "x972iubw3f7s4h9a2s1y79ucc",
"com.docker.swarm.service.id": "t3p2tnr7qg5nfldf7jqp99oa6",
"com.docker.swarm.service.name": "MyExitedImage",
"com.docker.swarm.task": "",
"com.docker.swarm.task.id": "yj9zptsznwfnq2qh1cdhlvh4i",
"com.docker.swarm.task.name": "MyExitedImage.2.yj9zptsznwfnq2qh1cdhlvh4i"
},
"State": "exited",
"Status": "Exited(3221225786)3daysago",
"HostConfig": {
"NetworkMode": "default"
},
"NetworkSettings": {
"Networks": {
"ingress": {
"IPAMConfig": {
"IPv4Address": "10.255.46.11"
},
"Links": null,
"Aliases": null,
"NetworkID": "l426kv9m20yvsr9e0d8zdi0za",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
},
"Mounts": []
}]
Loading