1

I want to download already existing Dialogflow logs from Stackdriver in JSON format. As a beginner i´m surprised how difficult this is. The graphical interface only allows downloads of up to 300 logs which is not enough for my purposes. Since the logs are already there I can not solve this with the export function since it only processes new logs.

I followed advice in How to export previous logs in Stackdriver and ended up using this command to download the logs gcloud logging read --project=myproject --freshness 30d --format=json > C:\Users\Gabriel\Desktop\log.json.

The resulting JSON file is almost exactly what I need, BUT the most important information like what was said to the Dialogflow bot is not formatted as JSON but instead a messy text string under the key "textPayLoad", for example: textPayload = "Dialogflow Request : {\"session\":\"usr117\",\"query_input\":\"{\\n \\\"text\\\": {\\n \\\"textInputs\\\": [{\\n \\\"text\\\": \\\"Hello\

Is there any relatively simple way to download the logs as structured JSON files? The Google documentation on the topic is to complicated for me to grasp.

Gabriel
  • 21
  • 2
  • I ran the same command in a linux environment and I did not run into this issue. I suspect that it could be how Windows is parsing the logs. I will test this on a Windows Machine and get back to you. – Jason Sep 25 '19 at 03:32
  • @Jason Thanks for the info, I will try with Linux. What distro are you running? (Don’t know if it matters) – Gabriel Sep 25 '19 at 13:00
  • Tried using Ubuntu for Windows 10, and the textPayload is still formatted as a string with line breaks. – Gabriel Sep 25 '19 at 18:17
  • I think the issue might be that the information was logged as a textPayLoad instead of a jsonPayLoad. Maybe I have to manually parse the string into JSON to solve this now? – Gabriel Sep 25 '19 at 18:29
  • The textPayLoad line will always produce a text rather than a properly parsed JSON format. I believe there is a way to change that to use json payload instead of textpayload, but that requires a custom fluentd agent (not putting as an answer because I can't confirm atm) – Patrick W Sep 25 '19 at 23:10

0 Answers0