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

⭐️ Add GCP monitoring alert policies #805

Merged
merged 2 commits into from
Jan 20, 2023
Merged

Conversation

imilchev
Copy link
Member

@imilchev imilchev commented Jan 19, 2023

./cnquery run gcp -c "gcp.project.monitoring.alertPolicies{*}"discover related assets for 1 asset(s)
→ resolved assets resolved-assets=1
gcp.project.monitoring.alertPolicies: [
  0: {
    updatedBy: "[email protected]"
    validity: null
    conditions: [
      0: {
        absent: null
        displayName: "New condition"
        matchedLog: null
        monitoringQueryLanguage: null
        name: "projects/manuel-development-2/alertPolicies/13858885952422700290/conditions/13858885952422701115"
        threshold: {
          comparison: "COMPARISON_GT"
          denominatorFilter: ""
          duration: 0000-01-01 00:17:30 +0017 LMT
          evaluationMissingData: "EVALUATION_MISSING_DATA_UNSPECIFIED"
          filter: "metric.type=\"logging.googleapis.com/user/log-metric-filter-and-alerts-exist-for-project-ownership-assignments-changes\""
          thresholdValue: 1.000000
        }
      }
    ]
    displayName: "alert-ensure-log-metric-filter-and-alerts-exist-for-project-ownership-assignments-changes"
    projectId: "manuel-development-2"
    labels: {}
    combiner: "OR"
    documentation: {
      content: "gcp--ensure-log-metric-filter-and-alerts-exist-for-project-ownership-assignments-changes"
      mimeType: "text/markdown"
    }
    name: "projects/manuel-development-2/alertPolicies/13858885952422700290"
    notificationChannelUrls: []
    updated: 2023-01-18 16:22:51.668249093 +0000 UTC
    enabled: true
    created: 2023-01-18 16:22:51.668249093 +0000 UTC
    alertStrategy: {
      autoClose: 0000-01-08 00:17:30 +0017 LMT
      notificationRateLimit: null
    }
    createdBy: "[email protected]"
  }
  1: {
    updatedBy: "[email protected]"
    validity: null
    conditions: [
      0: {
        absent: null
        displayName: "New condition"
        matchedLog: null
        monitoringQueryLanguage: null
        name: "projects/manuel-development-2/alertPolicies/14781749476325084227/conditions/14781749476325084442"
        threshold: {
          comparison: "COMPARISON_GT"
          denominatorFilter: ""
          duration: 0000-01-01 00:17:30 +0017 LMT
          evaluationMissingData: "EVALUATION_MISSING_DATA_UNSPECIFIED"
          filter: "metric.type=\"logging.googleapis.com/user/major-foo-1\""
          thresholdValue: 1.000000
        }
      }
    ]
    displayName: "alert-foo-bar-test-1"
    projectId: "manuel-development-2"
    labels: {}
    combiner: "OR"
    documentation: null
    name: "projects/manuel-development-2/alertPolicies/14781749476325084227"
    notificationChannelUrls: [
      0: "projects/manuel-development-2/notificationChannels/9884640812742514901"
    ]
    updated: 2023-01-18 18:40:38.212119022 +0000 UTC
    enabled: true
    created: 2023-01-18 18:40:38.212119022 +0000 UTC
    alertStrategy: {
      autoClose: 0000-01-08 00:17:30 +0017 LMT
      notificationRateLimit: null
    }
    createdBy: "[email protected]"
  }
]
./cnquery run gcp -c "gcp.project.logging.metrics{alertPolicies}"discover related assets for 1 asset(s)
→ resolved assets resolved-assets=1
gcp.project.logging.metrics: [
  0: {
    alertPolicies: [
      0: gcp.project.monitoringService.alertPolicy id = projects/manuel-development-2/alertPolicies/13858885952422700290
    ]
  }
  1: {
    alertPolicies: [
      0: gcp.project.monitoringService.alertPolicy id = projects/manuel-development-2/alertPolicies/14781749476325084227
    ]
  }
]

@imilchev imilchev requested a review from a team as a code owner January 19, 2023 11:43
Copy link
Contributor

@misterpantz misterpantz left a comment

Choose a reason for hiding this comment

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

Really good docs, @imilchev!

}

func (g *mqlGcpProject) GetMonitoring() (interface{}, error) {
projectId, err := g.Id()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct?

L18 uses another function to get the projectID:
g.Id() vs. g.ProjectId()

Copy link
Member Author

Choose a reason for hiding this comment

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

Those are 2 different resources. On L18 we are working with mqlGcpProjectMonitoringService that has a property projectId. Here we are working with a mqlGcpProject that has id.

Copy link
Contributor

@czunker czunker left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the new resources

@imilchev imilchev merged commit 4f1245e into main Jan 20, 2023
@imilchev imilchev deleted the ivan/gcp-monitoring-policy branch January 20, 2023 12:02
@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants