How to write json to Google Cloud Driver










1















I am using django for logging. Here is what I have so far:



from google.cloud import logging
client = logging.Client.from_service_account_json('file.json')
client.setup_logging()

LOGGING =

'version': 1,


'handlers':

'stackdriver':
'level': 'INFO',
'class': 'google.cloud.logging.handlers.CloudLoggingHandler',
'client': client,
,
,

'loggers':
'app':
'handlers': ['stackdriver'],
'level': 'INFO',
'propagate': False,
,





And here is how it shows up in Google Stackdriver:



enter image description here



Is there a way to actually add additional key/value fields instead of just having the json message be formatted as text? Can any fields be added except for the "message". How would this be done?










share|improve this question




























    1















    I am using django for logging. Here is what I have so far:



    from google.cloud import logging
    client = logging.Client.from_service_account_json('file.json')
    client.setup_logging()

    LOGGING =

    'version': 1,


    'handlers':

    'stackdriver':
    'level': 'INFO',
    'class': 'google.cloud.logging.handlers.CloudLoggingHandler',
    'client': client,
    ,
    ,

    'loggers':
    'app':
    'handlers': ['stackdriver'],
    'level': 'INFO',
    'propagate': False,
    ,





    And here is how it shows up in Google Stackdriver:



    enter image description here



    Is there a way to actually add additional key/value fields instead of just having the json message be formatted as text? Can any fields be added except for the "message". How would this be done?










    share|improve this question


























      1












      1








      1


      1






      I am using django for logging. Here is what I have so far:



      from google.cloud import logging
      client = logging.Client.from_service_account_json('file.json')
      client.setup_logging()

      LOGGING =

      'version': 1,


      'handlers':

      'stackdriver':
      'level': 'INFO',
      'class': 'google.cloud.logging.handlers.CloudLoggingHandler',
      'client': client,
      ,
      ,

      'loggers':
      'app':
      'handlers': ['stackdriver'],
      'level': 'INFO',
      'propagate': False,
      ,





      And here is how it shows up in Google Stackdriver:



      enter image description here



      Is there a way to actually add additional key/value fields instead of just having the json message be formatted as text? Can any fields be added except for the "message". How would this be done?










      share|improve this question
















      I am using django for logging. Here is what I have so far:



      from google.cloud import logging
      client = logging.Client.from_service_account_json('file.json')
      client.setup_logging()

      LOGGING =

      'version': 1,


      'handlers':

      'stackdriver':
      'level': 'INFO',
      'class': 'google.cloud.logging.handlers.CloudLoggingHandler',
      'client': client,
      ,
      ,

      'loggers':
      'app':
      'handlers': ['stackdriver'],
      'level': 'INFO',
      'propagate': False,
      ,





      And here is how it shows up in Google Stackdriver:



      enter image description here



      Is there a way to actually add additional key/value fields instead of just having the json message be formatted as text? Can any fields be added except for the "message". How would this be done?







      python django logging google-cloud-platform google-cloud-stackdriver






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 2:47







      David542

















      asked Nov 12 '18 at 23:08









      David542David542

      32.7k92250457




      32.7k92250457






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Yes, this is possible by enabling structured logging, see https://cloud.google.com/logging/docs/structured-logging.



          Specifically, you'd have to write your own parser that knows know to parse the log message you're emitting from Python.






          share|improve this answer























          • thanks for this response, I'll begin working on adding that in. WOuld you be able to show a super brief example of how this would be done in python with writing/using your own parser?

            – David542
            Nov 13 '18 at 19:06











          • I'd be happy to, could you update your question to include an example of what you'd like the structured log to look like?

            – Dustin Ingram
            Nov 13 '18 at 20:28












          • @David542 Are you able to update your question to include an example?

            – Dustin Ingram
            Nov 20 '18 at 22:18










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271418%2fhow-to-write-json-to-google-cloud-driver%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Yes, this is possible by enabling structured logging, see https://cloud.google.com/logging/docs/structured-logging.



          Specifically, you'd have to write your own parser that knows know to parse the log message you're emitting from Python.






          share|improve this answer























          • thanks for this response, I'll begin working on adding that in. WOuld you be able to show a super brief example of how this would be done in python with writing/using your own parser?

            – David542
            Nov 13 '18 at 19:06











          • I'd be happy to, could you update your question to include an example of what you'd like the structured log to look like?

            – Dustin Ingram
            Nov 13 '18 at 20:28












          • @David542 Are you able to update your question to include an example?

            – Dustin Ingram
            Nov 20 '18 at 22:18















          0














          Yes, this is possible by enabling structured logging, see https://cloud.google.com/logging/docs/structured-logging.



          Specifically, you'd have to write your own parser that knows know to parse the log message you're emitting from Python.






          share|improve this answer























          • thanks for this response, I'll begin working on adding that in. WOuld you be able to show a super brief example of how this would be done in python with writing/using your own parser?

            – David542
            Nov 13 '18 at 19:06











          • I'd be happy to, could you update your question to include an example of what you'd like the structured log to look like?

            – Dustin Ingram
            Nov 13 '18 at 20:28












          • @David542 Are you able to update your question to include an example?

            – Dustin Ingram
            Nov 20 '18 at 22:18













          0












          0








          0







          Yes, this is possible by enabling structured logging, see https://cloud.google.com/logging/docs/structured-logging.



          Specifically, you'd have to write your own parser that knows know to parse the log message you're emitting from Python.






          share|improve this answer













          Yes, this is possible by enabling structured logging, see https://cloud.google.com/logging/docs/structured-logging.



          Specifically, you'd have to write your own parser that knows know to parse the log message you're emitting from Python.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 17:36









          Dustin IngramDustin Ingram

          3,0491125




          3,0491125












          • thanks for this response, I'll begin working on adding that in. WOuld you be able to show a super brief example of how this would be done in python with writing/using your own parser?

            – David542
            Nov 13 '18 at 19:06











          • I'd be happy to, could you update your question to include an example of what you'd like the structured log to look like?

            – Dustin Ingram
            Nov 13 '18 at 20:28












          • @David542 Are you able to update your question to include an example?

            – Dustin Ingram
            Nov 20 '18 at 22:18

















          • thanks for this response, I'll begin working on adding that in. WOuld you be able to show a super brief example of how this would be done in python with writing/using your own parser?

            – David542
            Nov 13 '18 at 19:06











          • I'd be happy to, could you update your question to include an example of what you'd like the structured log to look like?

            – Dustin Ingram
            Nov 13 '18 at 20:28












          • @David542 Are you able to update your question to include an example?

            – Dustin Ingram
            Nov 20 '18 at 22:18
















          thanks for this response, I'll begin working on adding that in. WOuld you be able to show a super brief example of how this would be done in python with writing/using your own parser?

          – David542
          Nov 13 '18 at 19:06





          thanks for this response, I'll begin working on adding that in. WOuld you be able to show a super brief example of how this would be done in python with writing/using your own parser?

          – David542
          Nov 13 '18 at 19:06













          I'd be happy to, could you update your question to include an example of what you'd like the structured log to look like?

          – Dustin Ingram
          Nov 13 '18 at 20:28






          I'd be happy to, could you update your question to include an example of what you'd like the structured log to look like?

          – Dustin Ingram
          Nov 13 '18 at 20:28














          @David542 Are you able to update your question to include an example?

          – Dustin Ingram
          Nov 20 '18 at 22:18





          @David542 Are you able to update your question to include an example?

          – Dustin Ingram
          Nov 20 '18 at 22:18

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271418%2fhow-to-write-json-to-google-cloud-driver%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          政党

          天津地下鉄3号線