diff --git a/LICENSE.TXT b/LICENSE.TXT new file mode 100644 index 0000000..3ff066e --- /dev/null +++ b/LICENSE.TXT @@ -0,0 +1,26 @@ +Copyright (c) 2008-2015, Dynatrace LLC +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the dynaTraceRuxit software nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + diff --git a/timeseries-examples/Node.js/LICENSE.TXT b/timeseries-examples/Node.js/LICENSE.TXT new file mode 100644 index 0000000..3ff066e --- /dev/null +++ b/timeseries-examples/Node.js/LICENSE.TXT @@ -0,0 +1,26 @@ +Copyright (c) 2008-2015, Dynatrace LLC +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the dynaTraceRuxit software nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + diff --git a/timeseries-examples/Node.js/README.md b/timeseries-examples/Node.js/README.md new file mode 100644 index 0000000..a840fa2 --- /dev/null +++ b/timeseries-examples/Node.js/README.md @@ -0,0 +1,24 @@ +## Overview + +This Ruxit timeseries data export API example demonstrate the export of CPU timeseries for a given host and how to +chart the resulting data points by using Google charts. +Mind that a Node.js service wrapper is used to cope with the Browsers security restriction to only load resources +from the same origin. The service wrapper also hides the secret API token for accessing the Ruxit tenant data instead +of exposing it within the JavaScript. + +### Ruxit data export API documentation + +The full API documentation can be found here: +https://ruxit.com/help/api-documentation/v1/timeseries + +####`API key` +The API key for your Ruxit tenant. You can generate a key by following these steps + +1. go to your Ruxit environment: https://{tenant}.live.ruxit.com +2. Click the burger menu in the right upper corner and select **Integration** +3. You will see the "API" section; +4. Enter a description label and click on **Generate** +5. copy it and use it in your data export API examples + +##License +This module is provided under BSD-3-Clause license. Please check out the details in the LICENSE.txt diff --git a/timeseries-examples/Node.js/app.js b/timeseries-examples/Node.js/app.js new file mode 100644 index 0000000..5d5134f --- /dev/null +++ b/timeseries-examples/Node.js/app.js @@ -0,0 +1,41 @@ +// +// Local Node.js service that wraps Ruxit Data Export API calls for local JavaScript/Browser usage. +// +var express = require('express'); +var app = express(); +var https = require('https'); + +app.use(express.static('public')); + +var YOUR_API_TOKEN = "j2pnF2JGR9mhF1ABFna1_"; +var YOUR_HOST = "HOST-A3C4D3D278C161FA"; + +// +// Read the CPU of a given host and return the JSON result +// +app.get('/cpu', function (req, res) { + var options = { + host: 'kyp91462.live.ruxit.com', + path: '/api/v1/timeseries/?Api-Token=' + YOUR_API_TOKEN + '&relativeTime=hour&entity=' + YOUR_HOST + '&aggregationType=AVG×eriesId=com.ruxit.builtin:host.cpu.user' + }; + + callback = function(response) { + var str = ''; + response.on('data', function (chunk) { + str += chunk; + }); + + // all data was received, send the result as JSON + response.on('end', function () { + res.send(str); + }); + } + + https.request(options, callback).end(); +}); + +var server = app.listen(8080, function () { + var host = server.address().address; + var port = server.address().port; + console.log('Example app listening at http://%s:%s', host, port); +}); \ No newline at end of file diff --git a/timeseries-examples/Node.js/public/index.html b/timeseries-examples/Node.js/public/index.html new file mode 100644 index 0000000..3725403 --- /dev/null +++ b/timeseries-examples/Node.js/public/index.html @@ -0,0 +1,43 @@ + + + + + + + +
+ + \ No newline at end of file