Timeboard API
Timeboard 엔드포인트를 사용하면 타임보드를 프로그래밍 방식으로 생성, 업데이트, 삭제, 조회할 수 있어요. 다만 이 엔드포인트는 더 이상 사용하지 않는(오래된) 방식이니, 새 대시보드 엔드포인트를 사용하는 것이 좋습니다.
출처: 문서
본문
{% alert level="warning" %} 이 엔드포인트는 더 이상 사용하지 않아요(outdated). 새 Dashboard 엔드포인트를 대신 사용하세요. {% /alert %}
Timeboard 엔드포인트를 사용하면 타임보드를 프로그래밍 방식으로 생성, 업데이트, 삭제, 조회할 수 있어요.
타임보드 생성
시그니처
POST https://api.datadoghq.com/api/v1/dash
인자
-
title[필수]: 대시보드의 이름. -
description[필수]: 대시보드 내용에 대한 설명. -
graphs[선택, 기본값=None]: 그래프 정의 목록. 그래프 정의는 다음 형식을 따릅니다:title[필수]: 그래프의 이름.definition[선택, 기본값=None]:events[선택, 기본값=None]: 이벤트 오버레이 쿼리.requests[선택, 기본값=None]: 메트릭 쿼리, 라인 유형, 스타일, 조건부 형식, 집계기.viz[선택, 기본값=timeseries]: 시각화 유형.
-
template_variables[선택, 기본값=None]: 대시보드 템플릿팅을 위한 템플릿 변수 목록. 템플릿 변수 정의는 다음 형식을 따릅니다:name[필수]: 변수의 이름.prefix[선택, 기본값=None]: 변수와 연관된 태그 접두사. 이 접두사가 있는 태그만 변수 드롭다운에 나타나요.default[선택, 기본값=None]: 대시보드 로드 시 템플릿 변수의 기본값.
예시
{% tab title="Python" %}
from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
title = "My Timeboard"
description = "An informative timeboard."
graphs = [{
"definition": {
"events": [],
"requests": [
{"q": "avg:system.mem.free{*}"}
],
"viz": "timeseries"
},
"title": "Average Memory Free"
}]
template_variables = [{
"name": "host1",
"prefix": "host",
"default": "host:my-host"
}]
read_only = True
api.Timeboard.create(title=title,
description=description,
graphs=graphs,
template_variables=template_variables,
read_only=read_only)
{% /tab %}
{% tab title="Ruby" %}
require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
# Create a timeboard.
title = 'My First Metrics'
description = 'And they are marvelous.'
graphs = [{
"definition" => {
"events" => [],
"requests" => [{
"q" => "avg:system.mem.free{*}"
}],
"viz" => "timeseries"
},
"title" => "Average Memory Free"
}]
template_variables = [{
"name" => "host1",
"prefix" => "host",
"default" => "host:my-host"
}]
dog.create_dashboard(title, description, graphs, template_variables)
{% /tab %}
{% tab title="Bash" %}
api_key=<DATADOG_API_KEY>
app_key=<DATADOG_APPLICATION_KEY>
curl -X POST -H "Content-type: application/json" \
-d '{
"graphs" : [{
"title": "Average Memory Free",
"definition": {
"events": [],
"requests": [
{"q": "avg:system.mem.free{*}"}
],
"viz": "timeseries"
}
}],
"title" : "Average Memory Free Shell",
"description" : "A dashboard with memory info.",
"template_variables": [{
"name": "host1",
"prefix": "host",
"default": "host:my-host"
}],
"read_only": "True"
}' \
"https://api.datadoghq.com/api/v1/dash?api_key=${api_key}&application_key=${app_key}"
{% /tab %}
타임보드 업데이트
시그니처
PUT https://api.datadoghq.com/api/v1/dash/<TIMEBOARD_ID>
인자
-
title[필수]: 대시보드의 이름. -
description[필수]: 대시보드 내용에 대한 설명. -
graphs[필수]: 그래프 정의 목록. 그래프 정의는 다음 형식을 따릅니다:title[필수]: 그래프의 이름.definition[필수]: 그래프 정의. 예시:{"requests": [{"q": "system.cpu.idle{*} by {host}"}
-
template_variables[선택, 기본값=None]: 대시보드 템플릿팅을 위한 템플릿 변수 목록. 템플릿 변수 정의는 다음 형식을 따릅니다:-
name[필수]: 변수의 이름. -
prefix[선택, 기본값=None]: 변수와 연관된 태그 접두사. 이 접두사가 있는 태그만 변수 드롭다운에 나타나요. -
default[선택, 기본값=None]: 대시보드 로드 시 템플릿 변수의 기본값.
-
예시
{% tab title="Python" %}
from datadog import initialize, api
options = {'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'}
initialize(**options)
title = 'My Timeboard'
description = 'A new and improved timeboard!'
graphs = [{'definition': {'events': [],
'requests': [{
'q': 'avg:system.mem.free{*} by {host}'}],
'viz': 'timeseries'},
'title': 'Average Memory Free By Host'}]
template_variables = [{'name': 'host1', 'prefix': 'host',
'default': 'host:my-host'}]
read_only = True
api.Timeboard.update(
4952,
title=title,
description=description,
graphs=graphs,
template_variables=template_variables,
read_only=read_only,
)
{% /tab %}
{% tab title="Ruby" %}
require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
dash_id = '2551'
title = 'New and Improved Timeboard'
description = 'This has all the new hotness.'
graphs = [{
"definition" => {
"events" => [],
"requests" => [{
"q" => "avg:system.mem.free{*}"
}],
"viz" => "timeseries"
},
"title" => "Average Memory Free"
}]
template_variables = [{
"name" => "host1",
"prefix" => "host",
"default" => "host:my-host"
}]
dog.update_dashboard(dash_id, title, description, graphs, template_variables)
{% /tab %}
{% tab title="Bash" %}
api_key=<DATADOG_API_KEY>
app_key=<DATADOG_APPLICATION_KEY>
dash_id=2532
# Create a dashboard to get. Use jq (http://stedolan.github.io/jq/download/) to get the dash id.
dash_id=$(curl -X POST -H "Content-type: application/json" \
-d '{
"graphs" : [{
"title": "Average Memory Free",
"definition": {
"events": [],
"requests": [
{"q": "avg:system.mem.free{*}"}
],
"viz": "timeseries"
}
}],
"title" : "Average Memory Free Shell",
"description" : "A dashboard with memory info.",
"template_variables": [{
"name": "host1",
"prefix": "host",
"default": "host:my-host"
}]
}' \
"https://api.datadoghq.com/api/v1/dash?api_key=${api_key}&application_key=${app_key}" | jq '.dash.id')
curl -X PUT -H "Content-type: application/json" \
-d '{
"graphs" : [{
"title": "Sum of Memory Free",
"definition": {
"events": [],
"requests": [
{"q": "sum:system.mem.free{*}"}
],
"viz": "timeseries"
}
}],
"title" : "Sum Memory Free Shell",
"description" : "An updated dashboard with memory info.",
"template_variables": [{
"name": "host1",
"prefix": "host",
"default": "host:my-host"
}]
}' \
"https://api.datadoghq.com/api/v1/dash/${dash_id}?api_key=${api_key}&application_key=${app_key}"
{% /tab %}
타임보드 삭제
기존 타임보드를 삭제합니다. 이 엔드포인트는 JSON 인자를 받지 않아요.
시그니처
DELETE https://api.datadoghq.com/api/v1/dash/<TIMEBOARD_ID>
인자
이 엔드포인트는 JSON 인자를 받지 않아요.
예시
{% tab title="Python" %}
from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
title = "My Timeboard"
description = "An informative timeboard."
graphs = [{
"definition": {
"events": [],
"requests": [
{"q": "avg:system.mem.free{*}"}
],
"viz": "timeseries"
},
"title": "Average Memory Free"
}]
template_variables = [{
"name": "host1",
"prefix": "host",
"default": "host:my-host"
}]
newboard = api.Timeboard.create(title=title,
description=description,
graphs=graphs,
template_variables=template_variables)
api.Timeboard.delete(newboard['dash']['id'])
{% /tab %}
{% tab title="Ruby" %}
require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
dash_id = '2534'
dog.delete_dashboard(dash_id)
{% /tab %}
{% tab title="Bash" %}
api_key=<DATADOG_API_KEY>
app_key=<DATADOG_APPLICATION_KEY>
dash_id=2471
# Create a dashboard to delete. Use jq (http://stedolan.github.io/jq/download/) to get the dash id.
dash_id=$(curl -X POST -H "Content-type: application/json" \
-d '{
"graphs" : [{
"title": "Average Memory Free",
"definition": {
"events": [],
"requests": [
{"q": "avg:system.mem.free{*}"}
],
"viz": "timeseries"
}
}],
"title" : "Average Memory Free Shell",
"description" : "A dashboard with memory info.",
"template_variables": [{
"name": "host1",
"prefix": "host",
"default": "host:my-host"
}]
}' \
"https://api.datadoghq.com/api/v1/dash?api_key=${api_key}&application_key=${app_key}" | jq '.dash.id')
curl -X DELETE "https://api.datadoghq.com/api/v1/dash/${dash_id}?api_key=${api_key}&application_key=${app_key}"
{% /tab %}
타임보드 조회
기존 대시보드의 정의를 가져옵니다.
시그니처
GET https://api.datadoghq.com/api/v1/dash/<TIMEBOARD_ID>
인자
이 엔드포인트는 JSON 인자를 받지 않아요.
예시
{% tab title="Python" %}
from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
api.Timeboard.get(4953)
{% /tab %}
{% tab title="Ruby" %}
require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
dash_id = '2542'
dog.get_dashboard(dash_id)
{% /tab %}
{% tab title="Bash" %}
api_key=<DATADOG_API_KEY>
app_key=<DATADOG_APPLICATION_KEY>
dash_id=2473
# Create a dashboard to get. Use jq (http://stedolan.github.io/jq/download/) to get the dash id.
dash_id=$(curl -X POST -H "Content-type: application/json" \
-d '{
"graphs" : [{
"title": "Average Memory Free",
"definition": {
"events": [],
"requests": [
{"q": "avg:system.mem.free{*}"}
],
"viz": "timeseries"
}
}],
"title" : "Average Memory Free Shell",
"description" : "A dashboard with memory info.",
"template_variables": [{
"name": "host1",
"prefix": "host",
"default": "host:my-host"
}]
}' \
"https://api.datadoghq.com/api/v1/dash?api_key=${api_key}&application_key=${app_key}" | jq '.dash.id')
curl "https://api.datadoghq.com/api/v1/dash/${dash_id}?api_key=${api_key}&application_key=${app_key}"
{% /tab %}
모든 타임보드 조회
모든 타임보드 정의를 가져옵니다.
시그니처
GET https://api.datadoghq.com/api/v1/dash
인자
이 엔드포인트는 JSON 인자를 받지 않아요.
예시
{% tab title="Python" %}
from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
print api.Timeboard.get_all()
{% /tab %}
{% tab title="Ruby" %}
require 'rubygems'
require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
dog.get_dashboards
{% /tab %}
{% tab title="Bash" %}
api_key=<DATADOG_API_KEY>
app_key=<DATADOG_APPLICATION_KEY>
curl "https://api.datadoghq.com/api/v1/dash?api_key=${api_key}&application_key=${app_key}"
{% /tab %}
더 알아보기 (Learn more)
도움이 되는 추가 문서, 링크, 아티클이에요: