{"_id":"577c393c87acf617003c400c","version":{"_id":"56ba46e2ce5d540d00e2d7aa","project":"56ba46e2ce5d540d00e2d7a7","__v":12,"createdAt":"2016-02-09T20:06:58.727Z","releaseDate":"2016-02-09T20:06:58.727Z","categories":["56ba46e3ce5d540d00e2d7ab","5771a6b145c7080e0072927f","5771a72eb0ea6b0e006a5221","5772e5b20a6d610e00dea073","577c3006b20f211700593629","57ae587bca3e310e00538155","57ae593a7c93fa0e001e6b50","57b1f8263ff6c519005cf074","582601f155b1060f00ec4173","582a62857a96051b0070b011","58ebfae58d5a860f00851fb9","590a75a1ec0d5e190095ab38"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"editedParams2":true,"project":"56ba46e2ce5d540d00e2d7a7","category":{"_id":"577c3006b20f211700593629","version":"56ba46e2ce5d540d00e2d7aa","project":"56ba46e2ce5d540d00e2d7a7","__v":0,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-07-05T22:09:10.383Z","from_sync":false,"order":7,"slug":"api","title":"Ingest API"},"user":"5732062ad720220e008ea1d2","__v":8,"parentDoc":null,"editedParams":true,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-05T22:48:28.992Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"status":200,"language":"json","code":"{ \"status\": \"ok\" }","name":""},{"code":"{ \"error\": \"Bad or missing parameters.\", \"code\": \"BadRequest\", \"status\": \"error\" }","name":"Bad Params","status":400,"language":"json"},{"status":400,"language":"json","code":"{ \"error\": \"Missing param hostname.\" }","name":"No Hostname"},{"code":"{ \"error\": \"Missing Credentials\" }","status":401,"language":"json"},{"status":403,"language":"json","code":"{ \"error\": \"Account not found or inactive\" }"}]},"settings":"577166bd3dd24019004c90a3","examples":{"codes":[{"name":null,"language":"curl","code":"curl \"https://logs.logdna.com/logs/ingest?hostname=EXAMPLE_HOST&mac=C0:FF:EE:C0:FF:EE&ip=10.0.1.101&now=$(date +%s)\" \\\n-u INSERT_INGESTION_KEY: \\\n-H \"Content-Type: application/json; charset=UTF-8\" \\\n-d \\\n'{ \n   \"lines\": [ \n     { \n       \"line\":\"This is an awesome log statement\", \n       \"app\":\"myapp\",\n       \"level\": \"INFO\",\n       \"env\": \"production\",\n       \"meta\": {\n         \"customfield\": {\n           \"nestedfield\": \"nestedvalue\"\n         }\n       }\n     }\n   ] \n}'"}]},"method":"post","auth":"required","params":[{"_id":"577c433a5b4f7b0e009f539b","ref":"","in":"path","required":false,"desc":"Required: The hostname of the source","default":"EXAMPLE_HOST","type":"string","name":"hostname"},{"_id":"577c3fe75fd4de0e00cc3be2","ref":"","in":"path","required":false,"desc":"Optional: The network mac address of the host computer","default":"C0:FF:EE:C0:FF:EE","type":"string","name":"mac"},{"_id":"577c3fe75fd4de0e00cc3be1","ref":"","in":"path","required":false,"desc":"Optional: The local IP address of the host computer","default":"10.0.1.101","type":"string","name":"ip"},{"_id":"577c439a7a157c0e002056ca","ref":"","in":"path","required":false,"desc":"Recommended: The source unix timestamp in milliseconds at the time of the request. Used to calculate time drift.","default":"","type":"timestamp","name":"now"}],"url":"/logs/ingest?hostname=:hostname&mac=:mac&ip=:ip&now=:now"},"isReference":true,"order":0,"body":"#### Post it\n1. Click the **Test in the API Explorer** button at the bottom of the page\n2. Hit the green key icon and enter your <a href=\"https://app.logdna.com/manage/profile\" target=\"_blank\">LogDNA Ingestion Key</a>\n3. Copy and paste the example JSON below into the **Body Content** text field. Be sure to replace ```INSERT_UNIX_TIMESTAMP``` with the unix timestamp of the log line, preferably in milliseconds. Then click the green **Try It!** button.\n\nIf you <a href=\"https://app.logdna.com\" target=\"_blank\">sign in</a> to the LogDNA log viewer, you'll now see the log line **\"This is an awesome log statement\"** live in the log viewer!\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{ \\n  \\\"lines\\\": [ \\n    { \\n      \\\"timestamp\\\": INSERT_UNIX_TIMESTAMP, \\n      \\\"line\\\":\\\"This is an awesome log statement\\\", \\n      \\\"app\\\":\\\"myapp\\\",\\n      \\\"level\\\": \\\"INFO\\\",\\n      \\\"meta\\\": {\\n        \\\"customfield\\\": {\\n          \\\"nestedfield\\\": \\\"nestedvalue\\\"\\n        }\\n      }\\n    }\\n  ] \\n}\",\n      \"language\": \"json\",\n      \"name\": \"JSON\"\n    }\n  ]\n}\n[/block]\n#### Curl it\nIf you like the good 'ol fashioned terminal, you can use the curl statement instead, but be sure to replace ```INSERT_INGESTION_KEY``` with your <a href=\"https://app.logdna.com/manage/profile\" target=\"_blank\">LogDNA Ingestion Key</a> and ```INSERT_UNIX_TIMESTAMP``` with the timestamp of the log line, preferably in milliseconds.\n\n#### Tweak it\nIn addition to **basic auth**, we also support an **HTTP query string** with the format, ```&apikey=your-ingestion-key``` as well as a **header token** with the format ```apikey:your-ingestion-key```. While we appreciate thoroughness, *please do not use more than one method of authentication per request*! There is also a maximum payload size of 10 MB.\n\n#### Metadata\nMeta is a field reserved for custom information associated with a log line. To add metadata to an API call, specify the ```meta``` field under the lines object. Metadata can be viewed inside that line's [context](doc:context).\n\nWARNING: If inconsistent value types are used, that line's metadata, will not be parsed. For example, if a line is passed with a meta object, such as `meta.myfield` of type String, any subsequent lines with `meta.myfield` must have a String as the value type for `meta.myfield`.","excerpt":"Posting to `/logs/ingest` will send your log statements to the LogDNA log viewer","slug":"api","type":"endpoint","title":"/logs/ingest"}

post/logs/ingest

Posting to `/logs/ingest` will send your log statements to the LogDNA log viewer

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

hostname:
stringEXAMPLE_HOST
Required: The hostname of the source
mac:
stringC0:FF:EE:C0:FF:EE
Optional: The network mac address of the host computer
ip:
string10.0.1.101
Optional: The local IP address of the host computer
now:
timestamp
Recommended: The source unix timestamp in milliseconds at the time of the request. Used to calculate time drift.

Examples


Result Format


Documentation

#### Post it 1. Click the **Test in the API Explorer** button at the bottom of the page 2. Hit the green key icon and enter your <a href="https://app.logdna.com/manage/profile" target="_blank">LogDNA Ingestion Key</a> 3. Copy and paste the example JSON below into the **Body Content** text field. Be sure to replace ```INSERT_UNIX_TIMESTAMP``` with the unix timestamp of the log line, preferably in milliseconds. Then click the green **Try It!** button. If you <a href="https://app.logdna.com" target="_blank">sign in</a> to the LogDNA log viewer, you'll now see the log line **"This is an awesome log statement"** live in the log viewer! [block:code] { "codes": [ { "code": "{ \n \"lines\": [ \n { \n \"timestamp\": INSERT_UNIX_TIMESTAMP, \n \"line\":\"This is an awesome log statement\", \n \"app\":\"myapp\",\n \"level\": \"INFO\",\n \"meta\": {\n \"customfield\": {\n \"nestedfield\": \"nestedvalue\"\n }\n }\n }\n ] \n}", "language": "json", "name": "JSON" } ] } [/block] #### Curl it If you like the good 'ol fashioned terminal, you can use the curl statement instead, but be sure to replace ```INSERT_INGESTION_KEY``` with your <a href="https://app.logdna.com/manage/profile" target="_blank">LogDNA Ingestion Key</a> and ```INSERT_UNIX_TIMESTAMP``` with the timestamp of the log line, preferably in milliseconds. #### Tweak it In addition to **basic auth**, we also support an **HTTP query string** with the format, ```&apikey=your-ingestion-key``` as well as a **header token** with the format ```apikey:your-ingestion-key```. While we appreciate thoroughness, *please do not use more than one method of authentication per request*! There is also a maximum payload size of 10 MB. #### Metadata Meta is a field reserved for custom information associated with a log line. To add metadata to an API call, specify the ```meta``` field under the lines object. Metadata can be viewed inside that line's [context](doc:context). WARNING: If inconsistent value types are used, that line's metadata, will not be parsed. For example, if a line is passed with a meta object, such as `meta.myfield` of type String, any subsequent lines with `meta.myfield` must have a String as the value type for `meta.myfield`.

User Information

Try It Out


post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}