[go: nahoru, domu]

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

monitoring: listAlertPolicies does not return policy.alertStrategy #4686

Closed
sourceful-alex opened this issue Sep 20, 2023 · 1 comment
Closed
Labels
api: monitoring Issues related to the Cloud Monitoring API.

Comments

@sourceful-alex
Copy link
sourceful-alex commented Sep 20, 2023

The response from alertPolicyServiceClient.listAlertPolicies() does not include policy.alertStrategy.

alertStrategy is inlcuded in the API documentation https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#alertstrategy

I have verified that alertStrategy is included in the response when I manually make an API call. The policy in question has an alertStrategy set, with the autoClose value changed from the default.

Environment details

  • which product (packages/*): @google-cloud/monitoring version 4.0.0
  • OS: Kubuntu 23.04
  • Node.js version: v17.9.1
  • npm version: 8.11.0

Steps to reproduce

npm install --save @google-cloud/monitoring typescript ts-node

import { Monitoring } from '@google-cloud/monitoring';

const projectId = 'YOUR_GCP_PROJECT_ID';  // Replace with your GCP Project ID

// Initialize the Google Cloud Monitoring client
const monitoring = new Monitoring({
  projectId,
});

// Function to export alert policies
async function exportAlertPolicies() {
  const alertPolicyServiceClient = monitoring.alertPolicyServiceClient();
  const [alertPolicies] = await alertPolicyServiceClient.listAlertPolicies({
    name: `projects/${projectId}`,
  });

  return alertPolicies;
}
@product-auto-label product-auto-label bot added the api: monitoring Issues related to the Cloud Monitoring API. label Sep 20, 2023
@sofisl
Copy link
Contributor
sofisl commented Sep 21, 2023

Hi @sourceful-alex,

The documentation you're referencing is exposing the REST API, whereas this library is autogenerated code from grpc. Likely, this property hasn't been exposed (you can look through here, where alertStrategy is missing, and which is what we use to autogenerate the libraries). The REST API client library is here, and it seems like it does expose the alertStrategy property. You can use this submodule to directly interact with the monitoring REST API.

@sofisl sofisl closed this as completed Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: monitoring Issues related to the Cloud Monitoring API.
Projects
None yet
Development

No branches or pull requests

2 participants