{"_id":"57fcc4870312b20e00ac64fb","project":"5435687035740020002a1c04","__v":1,"category":{"_id":"57fcc4860312b20e00ac64c9","__v":0,"version":"57fcc4860312b20e00ac64c0","project":"5435687035740020002a1c04","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-01T21:33:28.863Z","from_sync":false,"order":8,"slug":"integration-examples","title":"Integration Examples"},"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"},"user":"5435682035740020002a1c01","parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-05-01T21:34:46.030Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"The source code for this example is available on the [Telemetry Agents Examples ](https://github.com/telemetryapp/agent_examples/tree/master/api) Github repository.\",\n  \"title\": \"Source Code Available\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/JiIUz5akTTSlx1PDFOhH_methods.png\",\n        \"methods.png\",\n        \"1397\",\n        \"277\",\n        \"#29a0f8\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n# Requirements\n\nYou'll need an OSX or Linux computer system to run through this guide. Windows is supported with Telemetry but some of the details here would be slightly different and thus it's out of scope.\n\nYou'll need access to a third party API.\n\n# Installation\n\nGet the most recent agent from the [Telemetry Agent](https://github.com/telemetryapp/gotelemetry_agent/releases) Github repository.\n\n# Configure Board\n\nVisit the [Telemetry Manager](https://manager.telemetryapp.com) application, login and either create a new board or use an existing one. Add a value widget to the board and take note of the *flow_tag*. You'll use this tag to send data to.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/9d1f4a4-Screen_Shot_2017-07-26_at_10.42.52_AM.png\",\n        \"Screen Shot 2017-07-26 at 10.42.52 AM.png\",\n        263,\n        170,\n        \"#232a34\"\n      ]\n    }\n  ]\n}\n[/block]\n# Configure Agent\n\nNext, we'll need to configure the agent to run the node script and send it to Telemetry.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#\\n# Server Configuration Parameters\\n#\\n\\n[server]\\n# API token found in the Agents tab in manager.telemetryapp.com\\napi_token = \\\"abc123abc123abc123abc123abc123abc123\\\"\\n# Submit new metrics in a batch at most every 1 second\\nsubmission_interval = \\\"1s\\\"\\n\\n[data]\\n# path = \\\"c:\\\\\\\\telemetry_agent.db\\\"\\n# WINDOWS USERS - Uncomment the line above and comment or remove the line below\\npath = \\\"/tmp/telemetry_agent.db\\\"\\n\\n#\\n# Flow Configurations \\n#\\n\\n#\\n# A specific flow\\n#\\n[[flow]]\\n# The flow tag\\ntag = \\\"api_text_1\\\"\\n# run the script every 2 seconds\\ninterval = \\\"10s\\\"\\n# The Lua script to run\\nscript = \\\"api.lua\\\"\\n\",\n      \"language\": \"toml\"\n    }\n  ]\n}\n[/block]\n# Write the Lua Script\n\nWrite a Lua script that looks like the following\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"local http = require(\\\"telemetry/http\\\")\\nlocal json = require(\\\"telemetry/json\\\")\\n\\n-- Retrieve the GET response as a string\\nlocal response = http.get(\\\"https://api.ipify.org?format=json\\\")\\n\\n-- Convert the JSON string to a Lua table\\nlocal table = json.decode(response)\\n\\n-- Send the result to a Telemetry text widget\\noutput.text = table.ip\",\n      \"language\": \"lua\"\n    }\n  ]\n}\n[/block]\n# Run the Agent\n\nWith the agent binary and the config file in the same directory start the agent by typing in your console:\n\n    gotelemetry_agent run -c config.toml\n\n\n# Viewing your Board and Notifications\n\nGo to [https://viewer.telemetryapp.com](https://viewer.telemetryapp.com) to create a new viewer and input its pairing code in the manager at [https://manager.telemetryapp.com/viewers](https://manager.telemetryapp.com/viewers)","excerpt":"","slug":"third-party-apis","type":"basic","title":"Third Party API"}
[block:callout] { "type": "info", "body": "The source code for this example is available on the [Telemetry Agents Examples ](https://github.com/telemetryapp/agent_examples/tree/master/api) Github repository.", "title": "Source Code Available" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/JiIUz5akTTSlx1PDFOhH_methods.png", "methods.png", "1397", "277", "#29a0f8", "" ] } ] } [/block] # Requirements You'll need an OSX or Linux computer system to run through this guide. Windows is supported with Telemetry but some of the details here would be slightly different and thus it's out of scope. You'll need access to a third party API. # Installation Get the most recent agent from the [Telemetry Agent](https://github.com/telemetryapp/gotelemetry_agent/releases) Github repository. # Configure Board Visit the [Telemetry Manager](https://manager.telemetryapp.com) application, login and either create a new board or use an existing one. Add a value widget to the board and take note of the *flow_tag*. You'll use this tag to send data to. [block:image] { "images": [ { "image": [ "https://files.readme.io/9d1f4a4-Screen_Shot_2017-07-26_at_10.42.52_AM.png", "Screen Shot 2017-07-26 at 10.42.52 AM.png", 263, 170, "#232a34" ] } ] } [/block] # Configure Agent Next, we'll need to configure the agent to run the node script and send it to Telemetry. [block:code] { "codes": [ { "code": "#\n# Server Configuration Parameters\n#\n\n[server]\n# API token found in the Agents tab in manager.telemetryapp.com\napi_token = \"abc123abc123abc123abc123abc123abc123\"\n# Submit new metrics in a batch at most every 1 second\nsubmission_interval = \"1s\"\n\n[data]\n# path = \"c:\\\\telemetry_agent.db\"\n# WINDOWS USERS - Uncomment the line above and comment or remove the line below\npath = \"/tmp/telemetry_agent.db\"\n\n#\n# Flow Configurations \n#\n\n#\n# A specific flow\n#\n[[flow]]\n# The flow tag\ntag = \"api_text_1\"\n# run the script every 2 seconds\ninterval = \"10s\"\n# The Lua script to run\nscript = \"api.lua\"\n", "language": "toml" } ] } [/block] # Write the Lua Script Write a Lua script that looks like the following [block:code] { "codes": [ { "code": "local http = require(\"telemetry/http\")\nlocal json = require(\"telemetry/json\")\n\n-- Retrieve the GET response as a string\nlocal response = http.get(\"https://api.ipify.org?format=json\")\n\n-- Convert the JSON string to a Lua table\nlocal table = json.decode(response)\n\n-- Send the result to a Telemetry text widget\noutput.text = table.ip", "language": "lua" } ] } [/block] # Run the Agent With the agent binary and the config file in the same directory start the agent by typing in your console: gotelemetry_agent run -c config.toml # Viewing your Board and Notifications Go to [https://viewer.telemetryapp.com](https://viewer.telemetryapp.com) to create a new viewer and input its pairing code in the manager at [https://manager.telemetryapp.com/viewers](https://manager.telemetryapp.com/viewers)