0

What is the header structure or can the header be customized when exporting logs using sinks to Cloud Pub/Sub topics?

When receiving the logs I want to reference metadata in the header. I want to know which GCP service that the log came from.

The header from the sent message to the receiver of the subscribed URL. When you configure a Pub/Sub topic in GCP and add a subscription to a URL. The header of the message sent to the URL.

DDDD
  • 3,790
  • 5
  • 33
  • 55

1 Answers1

0

I created a topic and a subscription. I then wrote a client that retrieved messages from the subscription and logged them. The payload for a sink wired to Pub/Sub contained:

{
  insertId:
  logName:
  receiveTimestamp:
  resource: {
     project_id:
     type:
  }
  textPayload:
  timestamp:
}
Kolban
  • 13,794
  • 3
  • 38
  • 60
  • My payload is different, but either way, I'm asking about the header of the request that sends the payload. I don't want to have to reference the payload, only the header. – DDDD Oct 03 '18 at 15:39
  • What kind of information are we hoping to find in the header? Do you have an example data field or piece of information that you are looking to acquire? – Kolban Oct 03 '18 at 16:12
  • I want to know which GCP service that the log came from. – DDDD Oct 03 '18 at 16:51
  • I checked the StackDriver docs. If we look in the payload of the published message that was published by StackDriver, the message contains a `resource` object and that object describes who/what issued the log message originally. To see the set of available sources run `gcloud logging resource-descriptors list`. – Kolban Oct 03 '18 at 18:58
  • Anything in the header identifying the service? – DDDD Oct 03 '18 at 19:19
  • When we look at a Pub/Sub message that is received, we see that the message contains a body. From what I can see, the body that is received from StackDriver looks like the message structure in the posted answer. I.e. it is a JSON string. In that JSON string there is an object called `resource` and that object describes the source of the original StackDriver logger. From what I can see, there don't appear to be any *headers* in the story. – Kolban Oct 03 '18 at 19:39
  • Okay, guess I'm looking for the header from the sent message to the receiver of the subscribed URL. When you configure a Pub/Sub topic in GCP and add a subscription to a URL. The header of the message sent to the URL. – DDDD Oct 03 '18 at 19:52