Python – How to add logging ‘tags’ to the stackdriver

How to add logging ‘tags’ to the stackdriver… here is a solution to the problem.

How to add logging ‘tags’ to the stackdriver

How does BigQuery or any other Google resource add these “tags” at the top of the stackdriver log entry?

enter image description here

I successfully added tags to my logs, but they don’t show up as “Tags” at the top. Here is an example of how I would create a log:

    self._queue.put_nowait({
            'info': info,
            'severity': record.levelname,
            'resource': resource,
            'labels': {'test': 'label'},
            'trace': trace,
            'span_id': span_id,
        })

How do I add these tags?

Solution

You can do this by clicking Add field to summary row. For example:

enter image description here

You can find more information about viewing logs and custom fields in this article.

Related Problems and Solutions