https://pulumi.com logo
#golang
Title
# golang
d

dazzling-rocket-15242

11/11/2019, 2:35 PM
Hey guys ... using the Go framework for Pulumi and so far enjoying it very much. I've run into an issue though trying to create a logMetric in GCP. The error is
unrecognized resource type (Check): gcp:logging/metric:Metric
. From what I can tell this is an error coming back from a grpc call against what I assume is the pulumi server. Any ideas? I haven't tried other languages and won't; will just go back to terraform 😞.
g

gentle-diamond-70147

11/11/2019, 4:38 PM
Can you share your code?
d

dazzling-rocket-15242

11/12/2019, 4:40 AM
Copy code
args := pLogging.MetricArgs{
		BucketOptions: map[string]interface{}{
			"exponentialBuckets": map[string]interface{}{
				"numFiniteBuckets": 64,
				"growthFactor":     2,
				"scale":            0.01,
			},
		},
		Description:     logMetric.description,
		Filter:          "resource.type=\"container\"\nresource.labels.cluster_name=\"redacted\"\nresource.labels.project_id=\"private\"\nresource.labels.zone:\"eyes-only\"\nresource.labels.container_name=\"nothing-to-see-here\"\nresource.labels.namespace_id=\"namespace\"\n\"Leaving \"\n",
		LabelExtractors: nil,
		MetricDescriptor: map[string]interface{}{
			"metric_kind": "DELTA",
			"value_type":  "DISTRIBUTION",
			"unit":        "1",
		},
		Name:           logMetric.name,
		Project:        logMetric.project,
		ValueExtractor: "",
	}

metricConfig, err := pLogging.NewMetric(ctx, logMetric.displayName, &args)
if err != nil {
		return err
	}
	ctx.Export(logMetric.displayName, metricConfig.Name())
g

gentle-diamond-70147

11/12/2019, 7:24 PM
Hmm, I don't get that error. I do get an error but it is actually talking to the Google API.
I get
error: Plan apply failed: Error creating Metric: googleapi: Error 400: A value extractor is required for a DISTRIBUTION value type or a GAUGE metric kind.
pLogging in your code is `pLogging "``github.com/pulumi/pulumi-gcp/sdk/go/gcp/logging``"` ?
d

dazzling-rocket-15242

11/12/2019, 8:48 PM
Thanks @gentle-diamond-70147, yes.
g

gentle-diamond-70147

11/12/2019, 8:49 PM
Which version of pulumi-gcp are you using?
d

dazzling-rocket-15242

11/12/2019, 8:49 PM
v1.4.1
I traced it to a similar point where it seems to be doing a grpc call to AWS, was guessing it's the pulumi backend.
I have this wrapped in a function within the pulumi.Run(), which has a bunch of other stuff within the stack. I haven't tried pulling this out to a separate stack.
g

gentle-diamond-70147

11/12/2019, 8:51 PM
Yea, the pulumi client persists the state to the Pulumi Console which runs on AWS.
That might be good to try - pull out that one particular resource to a separate app to see what you get.
My program was using 1.5.0 of pulumi-gcp, you could try that version too.
d

dazzling-rocket-15242

11/12/2019, 8:54 PM
Same error when updating go.mod to use v1.5.0
Other resource types within the same context work
g

gentle-diamond-70147

11/12/2019, 8:58 PM
@broad-dog-22463 any ideas on this one?
d

dazzling-rocket-15242

11/12/2019, 8:58 PM
Let me pull it into a separate stack. Certainly could be user error
Same error in new project
3 Views