How to write json to Google Cloud Driver
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:
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
add a comment |
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:
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
add a comment |
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:
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
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:
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
python django logging google-cloud-platform google-cloud-stackdriver
edited Nov 13 '18 at 2:47
David542
asked Nov 12 '18 at 23:08
David542David542
32.7k92250457
32.7k92250457
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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