-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ssong sumo 76740 metadata #7
Conversation
README.md
Outdated
| sumo-url | Yes | | HTTP Source URL | ||
| sumo-source-category | No | `dockerlog` | Source category to appear when searching on Sumo Logic by `_sourceCategory`. To include the log tag in the source category, use `{{.Tag}}`; see `tag`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add the same support for _sourceHost
and _sourceName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we allow the tag to be in _sourceHost
and _sourceName
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, basically 3 ways for customer to specify the metadata
I'm confused on the usage of
etc. |
Yeah, I agree that would probably be simpler. One issue is that the tag option is a Docker supported thing: https://docs.docker.com/engine/admin/logging/log_tags/ so it makes sense to follow this convention of using the A smaller issue is that Docker provides in their code a way to easily parse the tag in their |
Yea I think we'll want to look into this more, since we have 3 metadata fields, but only 1 |
Definitely. One thing we could do is to support the tag in the backend, in which case one possible approach would be to support templating in the 3 metadata fields, and also to support a fourth |
I wonder if we could:
|
The problem here is: the native docker log/stats blades don't have ability to resolve the template in So if we want make the docker logging driver has best compatible with native docker blades, Ideally And we can even give sumo-source-category a default value of |
@yuting-liu since we may want the native blades and logging driver has identical syntax on the metadata template |
896afad
to
5dd7b81
Compare
add few changes around the metadata part:
small fixes:
|
@latkin @rvmiller89 apply the change we discussed today. Please take a look before I merge it |
@latkin @rvmiller89 can you guys make it higher priority since @bgoleno want it out next week and we still have some validating process on the docker store side after we finalize the code |
DEVELOPER.md
Outdated
@@ -0,0 +1,45 @@ | |||
# Guide for developers | |||
This project is a plugin working in docker engine for delivering log to Sumo Logic cloud service through HTTP source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix some typos:
This project is a plugin for the docker engine, which delivers logs to Sumo Logic by pushing log messages through an HTTP source.
This is the guide for developers who want build and extend the plugin. If you just want use this plugin in your docker environment, please refer to the [readme file](README.md).
DEVELOPER.md
Outdated
```bash | ||
$ sudo bash ./plugin_install.sh | ||
``` | ||
If everything goes fine, you can verify the plugin correctly installed with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If everything goes fine, you can verify that the plugin is correctly installed with:
DEVELOPER.md
Outdated
```bash | ||
$ docker run --log-driver=sumologic --log-opt sumo-url=<url> -i -t ubuntu bash | ||
``` | ||
This will create a bash session in docker container and send all console contents to Sumo HTTP source as log lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create a bash session in a docker container and send all console contents to a Sumo Logic HTTP source as log lines
DEVELOPER.md
Outdated
This will create a bash session in docker container and send all console contents to Sumo HTTP source as log lines | ||
|
||
## Run unit test | ||
The unit test is written in `XXX_test.go` which `XXX` is the module to be tested. You can launch all unite tests with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unite = unit
README.md
Outdated
@@ -2,7 +2,7 @@ | |||
|
|||
A Docker logging driver plugin to send logs to Sumo Logic. | |||
|
|||
**Disclaimer:** This plugin is still being developed. We recommend using this plugin in non-production environments. | |||
**Disclaimer:** This plugin is still being developed. We recommend using this plugin in non-production environments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are announcing this at Illuminate we should remove this warning. (can be separate PR)
README.md
Outdated
| sumo-url | Yes | | HTTP Source URL | ||
| sumo-source-category | No | | Source category to appear when searching on Sumo Logic by `_sourceCategory`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, the source category of HTTP source will be used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all of these, "searching on" should be "searching in"
README.md
Outdated
| sumo-url | Yes | | HTTP Source URL | ||
| sumo-source-category | No | | Source category to appear when searching on Sumo Logic by `_sourceCategory`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, the source category of HTTP source will be used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not specified, the default source category configured for the HTTP source will be used.
README.md
Outdated
| sumo-url | Yes | | HTTP Source URL | ||
| sumo-source-category | No | | Source category to appear when searching on Sumo Logic by `_sourceCategory`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, the source category of HTTP source will be used | ||
| sumo-source-name | No | | Source name to appear when searching on Sumo Logic by `_sourceName`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, it will be the container's name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"If not specified, it will be the container's name" This should be in the "Default Value" column it sounds like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a little bit different, since default value is always a fixed value but these 3 options are actually a behavior (since you cannot specify a container's name
no matter whatever string you assigned here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I woudl suggest using code style
for the fixed value ones, and regular text description for others.
From casual user's perspective, if the "Default Value" column is empty, then they would expect no default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. make sense
README.md
Outdated
| sumo-url | Yes | | HTTP Source URL | ||
| sumo-source-category | No | | Source category to appear when searching on Sumo Logic by `_sourceCategory`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, the source category of HTTP source will be used | ||
| sumo-source-name | No | | Source name to appear when searching on Sumo Logic by `_sourceName`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, it will be the container's name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Use {{Tag}}
as the placeholder of tag
option." I think wording could be improved -- is it correct to say "Within the source name, the token {{Tag}}
will be replaced with the value of the Docker tag
option."
Similar for category/host.
README.md
Outdated
@@ -49,6 +52,9 @@ To specify additional logging driver options, you can use the `--log-opt NAME=VA | |||
| sumo-root-ca-path | No | | Set the path to a custom root certificate. | |||
| sumo-server-name | No | | Name used to validate the server certificate. By default, uses hostname of the `sumo-url`. | |||
| sumo-queue-size | No | 100 | The maximum number of log batches of size `sumo-batch-size` we can store in memory in the event of network failure, before we begin dropping batches. Thus in the worst case, the plugin will use `sumo-batch-size` * `sumo-queue-size` bytes of memory per container (default 100 MB). | |||
| tag | No | {{.ID}} | Specify a tag for messages, which interprets some markup. Default value is {{.ID}} (first 12 characters of the container ID). Refer to the [tag log-opt documentation] for customizing the log tag format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would update wording to "Specifies a tag for messages, which can be used in the 'source category', 'source name', and source host' fields. Certain tokens of the form {{X}}
are supported. Default value is {{.ID}}
, the first 12 characters of the container ID. Refer to the [tag log-opt documentation] for more information and a list of supported tokens."
|
||
for _, v := range re.FindAllSubmatchIndex([]byte(input), -1) { | ||
groups := []string{} | ||
for i := 0; i < len(v); i += 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it incrementing by 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's because the return of the FindAllSubmatchIndex() actually return a pattern as begin/end index of the matching sections
@@ -162,6 +162,11 @@ func (sumoLogger *sumoLogger) sendLogs(logs []*sumoLog) error { | |||
if sumoLogger.gzipCompression { | |||
request.Header.Add("Content-Encoding", "gzip") | |||
} | |||
if sumoLogger.sourceCategory != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does != ""
also handle nil
/null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because in golang the string cannot be nil (but *string
can)
README.md
Outdated
| sumo-url | Yes | | HTTP Source URL | ||
| sumo-source-category | No | | Source category to appear when searching on Sumo Logic by `_sourceCategory`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, the source category of HTTP source will be used | ||
| sumo-source-name | No | | Source name to appear when searching on Sumo Logic by `_sourceName`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, it will be the container's name | ||
| sumo-source-host | No | | Source host to appear when searching on Sumo Logic by `_sourceHost`. Use `{{Tag}}` as the placeholder of `tag` option. If not specified, it will be the machine host name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"If not specified, it will be the machine host name" should be in "default value" column
logger.go
Outdated
if sumoLogger.sourceCategory != "" { | ||
request.Header.Add("X-Sumo-Category", sumoLogger.sourceCategory) | ||
} | ||
request.Header.Add("X-Sumo-Name", sumoLogger.sourceName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know these should never be empty, but would be good to do != ""
check on these too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I can add the checking
Looking at https://docs.docker.com/engine/admin/logging/log_tags/ it seems that if users specify a I thought we were using it simply as an easy way to do token evaluation, then only expected the result to be included in sourceCategory, sourceHost, etc. Besides this, overall LGTM, just a bunch of small doc suggestions and a couple small code suggestions. |
The behavior of tag is decided by the logging driver. For example in Splunk plugin The tag can become a json field or a prefix depends on the format of message So yes, in sumo plugin, we decide the tag only be used in 3 metadata fields depends on the parameter given (not as prefix because the multiline processing) |
Ok, so when a Docker + Sumo user specifies a |
LGTM |
Merge to make a tag. feel free to comment |
Did you end up implementing the |
tag
support. https://docs.docker.com/engine/admin/logging/log_tags/sumo-source-category
. Currently supports explicit strings, but can specify{{.Tag}}
in the string to include the tag in the _sourceCategory. For example:test_category/{{.Tag}}/hello
X-Sumo-Name
andX-Sumo-Category
.