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

[WIP] Hosts API #2362

Merged
merged 2 commits into from
Apr 27, 2018
Merged
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 content/api/hosts/code_snippets/api-hosts-search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from datadog import initialize, api

options = {
'api_key': '<YOUR_API_KEY>',
'app_key': '<YOUR_APP_KEY>'
}

initialize(**options)

api.Hosts.search()
9 changes: 9 additions & 0 deletions content/api/hosts/code_snippets/api-hosts-search.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
app_key = '<YOUR_APP_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

dog.search_hosts()
6 changes: 6 additions & 0 deletions content/api/hosts/code_snippets/api-hosts-search.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
api_key=<YOUR_API_KEY>
app_key=<YOUR_APP_KEY>

curl -G "https://api.datadoghq.com/api/v1/hosts" \
-d "api_key=${api_key}" \
-d "application_key=${app_key}"
10 changes: 10 additions & 0 deletions content/api/hosts/code_snippets/api-hosts-totals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from datadog import initialize, api

options = {
'api_key': '<YOUR_API_KEY>',
'app_key': '<YOUR_APP_KEY>'
}

initialize(**options)

api.Hosts.totals()
9 changes: 9 additions & 0 deletions content/api/hosts/code_snippets/api-hosts-totals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
app_key = '<YOUR_APP_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

dog.host_totals()
6 changes: 6 additions & 0 deletions content/api/hosts/code_snippets/api-hosts-totals.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
api_key=<YOUR_API_KEY>
app_key=<YOUR_APP_KEY>

curl -G "https://api.datadoghq.com/api/v1/hosts/totals" \
-d "api_key=${api_key}" \
-d "application_key=${app_key}"
44 changes: 44 additions & 0 deletions content/api/hosts/code_snippets/result.api-hosts-search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
'total_returned': 1,
'host_list': [
{
'name': 'i-deadbeef',
'up': True,
'is_muted': False,
'apps': [
'agent'
],
'tags_by_source': {
'Datadog': [
'host:i-deadbeef'
],
'Amazon Web Services': [
'account:staging'
]
},
'aws_name': 'mycoolhost-1',
'metrics': {
'load': 0.5,
'iowait': 3.2,
'cpu': 99.0
},
'sources': [
'aws',
'agent'
],
'meta': {
'nixV': [
'Ubuntu',
'14.04',
'trusty'
]
},
'host_name': 'i-deadbeef',
'id': 123456,
'aliases': [
'mycoolhost-1'
]
}
],
'total_matching': 1
}
44 changes: 44 additions & 0 deletions content/api/hosts/code_snippets/result.api-hosts-search.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
["200", {
"total_returned": 1,
"host_list": [
{
"name": "i-deadbeef",
"up": true,
"is_muted": false,
"apps": [
"agent"
],
"tags_by_source": {
"Datadog": [
"host:i-deadbeef"
],
"Amazon Web Services": [
"account:staging"
]
},
"aws_name": "mycoolhost-1",
"metrics": {
"load": 0.5,
"iowait": 3.2,
"cpu": 99.0
},
"sources": [
"aws",
"agent"
],
"meta": {
"nixV": [
"Ubuntu",
"14.04",
"trusty"
]
},
"host_name": "i-deadbeef",
"id": 123456,
"aliases": [
"mycoolhost-1"
]
}
],
"total_matching": 1
}]
44 changes: 44 additions & 0 deletions content/api/hosts/code_snippets/result.api-hosts-search.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"total_returned": 1,
"host_list": [
{
"name": "i-deadbeef",
"up": true,
"is_muted": false,
"apps": [
"agent"
],
"tags_by_source": {
"Datadog": [
"host:i-deadbeef"
],
"Amazon Web Services": [
"account:staging"
]
},
"aws_name": "mycoolhost-1",
"metrics": {
"load": 0.5,
"iowait": 3.2,
"cpu": 99.0
},
"sources": [
"aws",
"agent"
],
"meta": {
"nixV": [
"Ubuntu",
"14.04",
"trusty"
]
},
"host_name": "i-deadbeef",
"id": 123456,
"aliases": [
"mycoolhost-1"
]
}
],
"total_matching": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'total_up':1750,'total_active':1759}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["200", {"total_up":1750,"total_active":1759}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"total_up":1750,"total_active":1759}
10 changes: 5 additions & 5 deletions content/api/hosts/hosts_mute.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
title: Mute a host
type: apicontent
order: 13.1
order: 13.3
external_redirect: /api/#mute-a-host
---

## Mute a host
##### ARGUMENTS

* **`end`** [*optional*, *default*=**None**]:
* **`end`** [*optional*, *default*=**None**]:
POSIX timestamp when the host is unmuted. If omitted, the host remains muted until explicitly unmuted.
* **`message`** [*optional*, *default*=**None**]:
* **`message`** [*optional*, *default*=**None**]:
Message to associate with the muting of this host.
* **`override`** [*optional*, *default*=**False**]:
If true and the host is already muted, replaces existing host mute settings.
* **`override`** [*optional*, *default*=**False**]:
If true and the host is already muted, replaces existing host mute settings.
4 changes: 2 additions & 2 deletions content/api/hosts/hosts_mute_code.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Mute a host
type: apicode
order: 13.1
order: 13.3
external_redirect: /api/#mute-a-host
---

Expand All @@ -10,4 +10,4 @@ external_redirect: /api/#mute-a-host
##### Example Request
{{< code-snippets basename="api-host-mute" >}}
##### Example Response
{{< code-snippets basename="result.api-host-mute" >}}
{{< code-snippets basename="result.api-host-mute" >}}
24 changes: 24 additions & 0 deletions content/api/hosts/hosts_search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Search hosts
type: apicontent
order: 13.1
external_redirect: /api/#search-hosts
---

## Search hosts
This endpoint allows searching for hosts by name, alias, or tag. Hosts live within the past 3 hours are included. Results are paginated with a max of 100 results at a time.

##### ARGUMENTS

* **`filter`** [*optional*, *default*=**None**]:
Query string to filter search results.
* **`sort_field`** [*optional*, *default*=**cpu**]:
Sort hosts by the given field.
Options: **status**, **apps**, **cpu**, **iowait**, **load**
* **`sort_dir`** [*optional*, *default*=**desc**]:
Direction of sort.
Options: **asc**, **desc**
* **`start`** [*optional*, *default*=**0**]:
Host result to start search from.
* **`count`** [*optional*, *default*=**100**]:
Number of host results to return. Max 100.
13 changes: 13 additions & 0 deletions content/api/hosts/hosts_search_code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Search hosts
type: apicode
order: 13.1
external_redirect: /api/#search-hosts
---

##### Signature
`GET https://api.datadoghq.com/api/v1/hosts`
##### Example Request
{{< code-snippets basename="api-hosts-search" >}}
##### Example Response
{{< code-snippets basename="result.api-hosts-search" >}}
13 changes: 13 additions & 0 deletions content/api/hosts/hosts_totals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Host totals
type: apicontent
order: 13.2
external_redirect: /api/#host-totals
---

## Host totals
This endpoint returns the total number of active and up hosts in your Datadog account. Active means the host has reported in the past hour, and up means it has reported in the past two hours.

##### ARGUMENTS

This end point takes no JSON arguments.
13 changes: 13 additions & 0 deletions content/api/hosts/hosts_totals_code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Host totals
type: apicode
order: 13.2
external_redirect: /api/#host-totals
---

##### Signature
`GET https://api.datadoghq.com/api/v1/hosts/totals`
##### Example Request
{{< code-snippets basename="api-hosts-totals" >}}
##### Example Response
{{< code-snippets basename="result.api-hosts-totals" >}}
4 changes: 2 additions & 2 deletions content/api/hosts/hosts_unmute.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Unmute a host
type: apicontent
order: 13.2
order: 13.4
external_redirect: /api/#unmute-a-host
---

## Unmute a host
##### ARGUMENTS

This end point takes no JSON arguments.
This end point takes no JSON arguments.
4 changes: 2 additions & 2 deletions content/api/hosts/hosts_unmute_code.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Unmute a host
type: apicode
order: 13.2
order: 13.4
external_redirect: /api/#unmute-a-host
---

Expand All @@ -10,4 +10,4 @@ external_redirect: /api/#unmute-a-host
##### Example Request
{{< code-snippets basename="api-host-unmute" >}}
##### Example Response
{{< code-snippets basename="result.api-host-unmute" >}}
{{< code-snippets basename="result.api-host-unmute" >}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,4 @@

initialize(**options)

# Search by `host` facet.
api.Infrastructure.search(q="hosts:database")

# Search by `metric` facet.
api.Infrastructure.search(q="metrics:system")

# Search all facets.
api.Infrastructure.search(q="test")
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,4 @@

dog = Dogapi::Client.new(api_key, app_key)

# Search by `host` facet.
dog.search("hosts:database")

# Search by `metric` facet.
dog.search("metrics:system")

# Search all facets.
dog.search("test")
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ app_key=<YOUR_APP_KEY>
curl -G "https://api.datadoghq.com/api/v1/search" \
-d "api_key=${api_key}" \
-d "application_key=${app_key}" \
-d "q=test"
-d "q=metrics:test"

Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@

{
'results': {
'hosts': [
'test.metric.host',
'test.tag.host'
],
'metrics': [
'test.metric.metric',
'test.tag.metric'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
["200", {
"results" => {
"metrics" => ["test.metric"]
}
}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"results": {
"metrics": [
"test.metric"
]
}
}
Loading