https://pulumi.com logo
#google-cloud
Title
# google-cloud
p

powerful-fish-66594

02/26/2024, 8:48 AM
Another notification related question: I'm trying to set-up an uptime check. Tried to follow https://www.pulumi.com/ai/answers/bLDyceC28wpkQkapHCc9PL/setting-uptime-checks-in-google-cloud but that one seems very much incomplete and outdated. So, after experimenting a little bit I ended up with:
Copy code
const uptimeCheckConfigId = `my_uptime_check_config`;
    const uptimeCheckConfig = new gcp.monitoring.UptimeCheckConfig(
        uptimeCheckConfigId,
        {
            timeout: '20s',
            period: '60s',
            httpCheck: {
                path: '/health/status',
                port: 80,
            },
            monitoredResource: {
                labels: {
                    host: ....myUrl,
                },
                type: 'uptime_url',
            },
            displayName: `Uptime check`,
        },
        { provider },
    );

const myAlertPolicy = new gcp.monitoring.AlertPolicy(
        `my_uptime_alert_policy`,
        {
            notificationChannels: ...myChannelIds...,
            combiner: 'OR',

            conditions: [
                {
                    displayName: `Uptime check FAILED`,
                    conditionThreshold: {
                        aggregations: [
                            {
                                alignmentPeriod: '420s',
                                crossSeriesReducer: 'REDUCE_COUNT_FALSE',
                                groupByFields: [
                                    'resource.label.project_id',
                                    'resource.label.host',
                                ],
                                perSeriesAligner: 'ALIGN_NEXT_OLDER',
                            },
                        ],
                        comparison: 'COMPARISON_GT',
                        duration: '60s',
                        filter: `resource.type = "uptime_url" AND metric.type = "<http://monitoring.googleapis.com/uptime_check/check_passed|monitoring.googleapis.com/uptime_check/check_passed>" AND resource.labels.check_id = "${uptimeCheckConfigId}"`,
                        thresholdValue: 1,
                        trigger: {
                            count: 1,
                        },
                    },
                },
            ],
            displayName: `Alert Policy check`,
        },
        { provider },
    );
However, I get
Error creating AlertPolicy: googleapi: Error 400: The supplied filter does not specify a valid combination of metric and monitored resource descriptors. The query will not return any time series.
I have a working example in a manually (= via GUI) created GCP project. I pretty much copied the alert policy from there. Only difference: It says
*metric*.labels.check_id
there instead of
*resource*.labels.check_id
. However, if I do the same in Pulumi, then the Uptime Check and the Alert Policy do not seem to be connected at all. It says "No policy connected". I'm pretty confused by this. Has anyone any clue?
2 Views