diff --git a/README.md b/README.md index 786481d..e9386ce 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,15 @@ The default level passed along with every log sent through this instance. By default the line has a maximum length of 16000 chars, this can be turned off with the value false. +##### tags + +* _Optional_ +* Type: `String[]` +* Default: `[]` + +List of tags used to dynamically group hosts. More information on tags is available at [How Do I Use Host Tags?](https://docs.logdna.com/docs/logdna-agent#section-how-do-i-use-host-tags-) + + ### log(line, [options]) --- #### line diff --git a/logdna/logdna.py b/logdna/logdna.py index 1bb3bc9..7d37099 100644 --- a/logdna/logdna.py +++ b/logdna/logdna.py @@ -23,6 +23,9 @@ def __init__(self, key, options={}): self.env = options['env'] if 'env' in options else '' self.setLevel(logging.DEBUG) + self.tags = [] + if 'tags' in options and isinstance(options['tags'], list): + self.tags.extend(options['tags']) self.max_length = True if 'max_length' in options: self.max_length = options['max_length'] @@ -71,7 +74,17 @@ def flush(self): self.flusher = Timer(defaults['FLUSH_NOW'], self.flush) self.flusher.start() else: - resp = requests.post(url=defaults['LOGDNA_URL'], json=data, auth=('user', self.key), params={ 'hostname': self.hostname, 'ip': self.ip, 'mac': self.mac if self.mac else None }, stream=True, timeout=defaults['MAX_REQUEST_TIMEOUT']) + resp = requests.post( + url=defaults['LOGDNA_URL'], + json=data, + auth=('user', self.key), + params={ + 'hostname': self.hostname, + 'ip': self.ip, + 'mac': self.mac if self.mac else None, + 'tags': self.tags if self.tags else None}, + stream=True, + timeout=defaults['MAX_REQUEST_TIMEOUT']) self.buf = [] self.bufByteLength = 0 if self.flusher: