정의 파일에서 Cloud Monitoring 대시보드 만들기
8744 단어 GCPTerraformCloud Monitoringtech
전언
Google Cloud의 Cloud Monitoring에서는 웹의 GUI 그래픽으로 대시보드를 만들 수 있습니다.이것은 매우 편리한 기능이다
이러한 단점을 보완하기 위해 클라우드 모니터링에는 정의 파일에서 대시보드를 생성할 수 있는 처리 대시보드의 API가 준비되어 있습니다.
대시보드 제작 프로세스
그럼에도 불구하고 제로에서 JSON 파일을 만드는 것은 매우 번거롭다
대시보드가 API로 제작되면 정의 파일을 수정하고 대시보드를 업데이트합니다.
전제 조건
Google Cloud SDK 설치
jq 명령이 설치되었음
Cloud Constore에서 대시보드 수동 제작
먼저 클라우드 콘스토어에서 차트를 보면서 대시보드를 만듭니다.
도표의 배치도 도형으로 할 수 있으니 우선 최종적으로 필요한 계기판을 만들어 보세요.
기존 대시보드에서 정의 파일 내보내기
대시보드 에셋 이름 가져오기
대시보드를 제작한 후 먼저
gcloud
명령을 사용하여 대시보드의 자원 이름을 얻습니다.gcloud monitoring dashboards list --format="table[box](displayName,name)"
displayName
는 디스플레이 이름이고 name
는 자원 이름이다.$ gcloud monitoring dashboards list --format="table[box](displayName,name)"
┌────────────────────┬───────────────────────────────────────────────────────────────────────┐
│ DISPLAY_NAME │ NAME │
├────────────────────┼───────────────────────────────────────────────────────────────────────┤
│ Sample Dashboard │ projects/xx4500xxxxxx/dashboards/1dxxf15x-773x-49cx-b97x-035xxfbf6bax │
│ Sample Dashboard 2 │ projects/xx4500xxxxxx/dashboards/exxx699x-ac7x-4xx8-bxx4-xxf78xxx334d │
└────────────────────┴───────────────────────────────────────────────────────────────────────┘
대시보드 정의 내보내기
다음에 가져온 자원 이름을 지정하고 대시보드 정의를 내보냅니다.
형식에 JSON을 지정합니다.
gcloud monitoring dashboards describe $DASHBOARD_RESOURCE_NAME --format="json" | jq "del(.etag,.name)" > ./dashboard.json
$DASHBOARD_RESOURCE_NAME
에서 방금 얻은 계기판의 자원 이름을 지정합니다.etag
, name
필드는 대시보드의 새 버전을 삭제할 필요가 없습니다.$ gcloud monitoring dashboards describe projects/xx4500xxxxxx/dashboards/1dxxf15x-773x-49cx-b97x-035xxfbf6bax --format="json" | jq "del(.etag,.name)"
{
"displayName": "Sample Dashboard",
"mosaicLayout": {
"columns": 12,
"tiles": [
{
"height": 4,
"widget": {
"title": "Audited Log bytes",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"minAlignmentPeriod": "60s",
"plotType": "STACKED_AREA",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"perSeriesAligner": "ALIGN_RATE"
},
"filter": "metric.type=\"logging.googleapis.com/byte_count\" resource.type=\"audited_resource\"",
"secondaryAggregation": {
"alignmentPeriod": "60s",
"perSeriesAligner": "ALIGN_MEAN"
}
}
}
}
],
"timeshiftDuration": "0s",
"yAxis": {
"label": "y1Axis",
"scale": "LINEAR"
}
}
},
"width": 5
},
{
"height": 4,
"widget": {
"title": "Log entries [MEAN]",
"xyChart": {
"chartOptions": {
"mode": "COLOR"
},
"dataSets": [
{
"minAlignmentPeriod": "60s",
"plotType": "LINE",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
"alignmentPeriod": "60s",
"perSeriesAligner": "ALIGN_RATE"
},
"filter": "metric.type=\"logging.googleapis.com/log_entry_count\" resource.type=\"global\"",
"secondaryAggregation": {
"alignmentPeriod": "60s",
"perSeriesAligner": "ALIGN_MEAN"
}
}
}
}
],
"timeshiftDuration": "0s",
"yAxis": {
"label": "y1Axis",
"scale": "LINEAR"
}
}
},
"width": 4,
"xPos": 5
}
]
}
}
이렇게 하면 정의 파일을 가져올 수 있습니다.정의 파일에서 대시보드 만들기
앞의 순서에서 대시보드 정의 파일을 내보냈으며 이 파일을 사용하여 대시보드를 다시 만듭니다.
gcloud
gcloud
명령을 사용하여 대시보드를 제작할 수 있습니다.gcloud monitoring dashboards create --config-from-file ./dashboard.json
명령 집행 예gcloud monitoring dashboards create --config-from-file ./dashboard.json
Created [83xxc447-8x14-4x4a-90cx-0bx064dxx0c9].
--config-from-file
옵션은 이전에 내보낸 정의 파일의 경로를 지정합니다.이번에 JSON 파일을 사용했는데 gcloud
명령이면 YAML 파일도 가능합니다.Terraform
Terraform도 지원됩니다.
resource "google_monitoring_dashboard" "dashboard" {
dashboard_json = file("./dashboard.json")
}
참고 자료
Reference
이 문제에 관하여(정의 파일에서 Cloud Monitoring 대시보드 만들기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/ptiringo/articles/bafd9a4f24e986텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)