Score:0

Drop-down menu for "Field name" does not show log_struct() logged jsonPayload in GCP LBM menu "Create logs metric" though logs in the Logs Explorer

I need LBMs on Google Cloud Platform of metric type "Distribution" to make time series charts with values like counts or duration for many labels in one go.

Example: for 10 different steps in the data workflow counts and duration of the day are logged in a dictionary and logged as jsonPayload using gcloud logging's log_struct().

Although I see logged events when looking at a month in the Logs Explorer, I cannot choose any of the jsonPayload items in the drop-down menu to create the needed Log-Based Metrics (LBM) from it so that I can choose them in Graphana to show graphs.

enter image description here

In this drop-down menu, I was expecting my key-value pairs that I logged during the run of a cloud function, but I cannot choose anything that was logged, I only see other jsonPayload system entries. This is how the logs look like.

enter image description here

Side-note: I save the jsonPayload with a middle branch in that the children are under one middle branch in the drop-down, for example jsonPayload.json_metadata.rows_count and not jsonPayload.rows_count. That makes it clearer what is coming from the Python logging. I do not think that this is a problem, but you never know. I cannot find this middle branch and its children in the drop-down menu so that I cannot make the needed LBMs. How to get a full drop-down menu for the "Field name"?

Score:0

The answer to this strange problem was easy, you need to run your function or code again. When the logs are too old, the drop-down forgets the entries. To be on the safe side, you should make a fresh run of the function so that it is younger than one hour, since that is the time the "Preview Logs" can look back that you can click on the same site.

I could still see the entries in the drop-down more than an hour after running the code, therefore, the drop-down menu keeps the entries for a longer time than one hour, but likely not longer than 12 hours, since when checking the drop-down after 18 hours, the entries were gone again.

I could not find a trick in two use cases how to load the drop-down from earlier logs, with a lot of tries and after research.

You can also hard-code the needed "Field name" without the drop-down, it will also work if you hit the right "tree" to reach your variable. The drop-down just makes it easier.

enter image description here

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.