{"_id":"57fcc4870312b20e00ac64ed","user":"547d27d12eaee50800ed1157","__v":0,"category":{"_id":"57fcc4860312b20e00ac64c7","__v":0,"version":"57fcc4860312b20e00ac64c0","project":"5435687035740020002a1c04","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-11-25T22:05:12.981Z","from_sync":false,"order":6,"slug":"agent-integration","title":"Data Agent"},"parentDoc":null,"project":"5435687035740020002a1c04","version":{"_id":"57fcc4860312b20e00ac64c0","project":"5435687035740020002a1c04","__v":1,"createdAt":"2016-10-11T10:52:54.637Z","releaseDate":"2016-10-11T10:52:54.637Z","categories":["57fcc4860312b20e00ac64c1","57fcc4860312b20e00ac64c2","57fcc4860312b20e00ac64c3","57fcc4860312b20e00ac64c4","57fcc4860312b20e00ac64c5","57fcc4860312b20e00ac64c6","57fcc4860312b20e00ac64c7","57fcc4860312b20e00ac64c8","57fcc4860312b20e00ac64c9","57fcc4860312b20e00ac64ca","57fcc4860312b20e00ac64cb"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"[APP-1265], [APP-1035]","version_clean":"5.2.0","version":"5.2"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-03-03T15:21:26.109Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"Perhaps the most basic way to use the Agent is to simply pipe data to it, which causes the data to be simply sent on to the TelemetryTV API. \n\nThis approach is best in situations where you either need to submit data based on external events that do not happen at regular intervals, or from an external application that needs to be running all the time. It's also great for tests since you don't need to worry about all the API interface details. For example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"echo '{\\\"test_value\\\":{\\\"value\\\":123}}' | \\\\\\n   TELEMETRY_API_TOKEN=YOURAPITOKEN \\\\\\n   gotelemetry_agent  \\\\\\n   -v debug \\\\\\n   pipe\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nAs you can see, the Agent takes the JSON-formatted object piped to it via stdin and uses it to build a request that is sent to the TelemetryTV API data endpoint. The data must be formatted as an object in which each property key corresponds to the name of a flow, and the corresponding value to the change you want to apply to that flow.\n\n### Determining the operation type\n\nBy default, the data passed to the Agent in pipe mode is treated as a Rails-style HTTPS PATCH operation—that is, the root properties of the affected flows are replaced with the piped-in data. In the example above, this would mean that only the `value` property of the existing contents of the `test_value` flow would be overwritten with the new value `123`, while everything else would remain untouched.\n\nThis approach works in most cases, but it may be problematic if you need to completely replace the contents of the flow. For this reason, you can optionally ask the Agent to use a straight HTTPS POST operation:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"echo '{\\\"test_value\\\":{\\\"value\\\":123}}' | \\\\\\n   TELEMETRY_API_TOKEN=YOURAPITOKEN \\\\\\n   gotelemetry_agent  \\\\\\n   -v debug \\\\\\n   pipe\\n   --post\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nIf you want a finer degree of control, the Agent also understand requests written using [JSON Patch](http://jsonpatch.com), a format supported by most modern scripting languages that allow you to specify arbitrary changes anywhere in the flow contents:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"echo '[{\\\"op\\\":\\\"replace\\\", \\\"path\\\":\\\"/value\\\", \\\"value\\\":123}]' | \\\\\\n   TELEMETRY_API_TOKEN=YOURAPITOKEN \\\\\\n   gotelemetry_agent  \\\\\\n   -v debug \\\\\\n   pipe\\n   --jsonpatch\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n## Sending notifications\n\nA variation of the pipe mode allows you to send [Notifications](doc:notifications) to a board. For example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"TELEMETRY_API_TOKEN=YOURAPITOKEN \\\\\\n  gotelemetry_agent \\\\\\n  notify \\\\\\n    --channel YOURCHANNELTAG \\\\\\n    --title 'Test Notification' \\\\\\n    --message \\\"Why, it's a lovely day out here.\\\" \\\\\\n    --duration 4000\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nFor more information on all the options available for this command, type:\n\n   gotelemetry_agent help notify","excerpt":"","slug":"piping-data-to-the-agent","type":"basic","title":"Piping Metrics"}
Perhaps the most basic way to use the Agent is to simply pipe data to it, which causes the data to be simply sent on to the TelemetryTV API. This approach is best in situations where you either need to submit data based on external events that do not happen at regular intervals, or from an external application that needs to be running all the time. It's also great for tests since you don't need to worry about all the API interface details. For example: [block:code] { "codes": [ { "code": "echo '{\"test_value\":{\"value\":123}}' | \\\n TELEMETRY_API_TOKEN=YOURAPITOKEN \\\n gotelemetry_agent \\\n -v debug \\\n pipe", "language": "shell" } ] } [/block] As you can see, the Agent takes the JSON-formatted object piped to it via stdin and uses it to build a request that is sent to the TelemetryTV API data endpoint. The data must be formatted as an object in which each property key corresponds to the name of a flow, and the corresponding value to the change you want to apply to that flow. ### Determining the operation type By default, the data passed to the Agent in pipe mode is treated as a Rails-style HTTPS PATCH operation—that is, the root properties of the affected flows are replaced with the piped-in data. In the example above, this would mean that only the `value` property of the existing contents of the `test_value` flow would be overwritten with the new value `123`, while everything else would remain untouched. This approach works in most cases, but it may be problematic if you need to completely replace the contents of the flow. For this reason, you can optionally ask the Agent to use a straight HTTPS POST operation: [block:code] { "codes": [ { "code": "echo '{\"test_value\":{\"value\":123}}' | \\\n TELEMETRY_API_TOKEN=YOURAPITOKEN \\\n gotelemetry_agent \\\n -v debug \\\n pipe\n --post", "language": "shell" } ] } [/block] If you want a finer degree of control, the Agent also understand requests written using [JSON Patch](http://jsonpatch.com), a format supported by most modern scripting languages that allow you to specify arbitrary changes anywhere in the flow contents: [block:code] { "codes": [ { "code": "echo '[{\"op\":\"replace\", \"path\":\"/value\", \"value\":123}]' | \\\n TELEMETRY_API_TOKEN=YOURAPITOKEN \\\n gotelemetry_agent \\\n -v debug \\\n pipe\n --jsonpatch", "language": "shell" } ] } [/block] ## Sending notifications A variation of the pipe mode allows you to send [Notifications](doc:notifications) to a board. For example: [block:code] { "codes": [ { "code": "TELEMETRY_API_TOKEN=YOURAPITOKEN \\\n gotelemetry_agent \\\n notify \\\n --channel YOURCHANNELTAG \\\n --title 'Test Notification' \\\n --message \"Why, it's a lovely day out here.\" \\\n --duration 4000", "language": "shell" } ] } [/block] For more information on all the options available for this command, type: gotelemetry_agent help notify