Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HELP NEEDED #365

Open
junaid360 opened this issue Jun 13, 2024 · 0 comments
Open

HELP NEEDED #365

junaid360 opened this issue Jun 13, 2024 · 0 comments

Comments

@junaid360
Copy link

can anyone help me how to include or filter in below. for ecample I need to filter by custom properties i.e. comments = customxyz

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> // The query we'll run against the web-based API // If you use a multi-line query, use a backslash '\' to indicate the next line is part of the string (may cause browser issues) // Alternatively, use a "+" to join the lines (preferred method) var swql="SELECT CONCAT(SUBSTRING(TOSTRING(DATETRUNC('MONTH',DATETIME)),1,4),SUBSTRING(TOSTRING(DATETRUNC('MONTH',DATETIME)),8,4)) AS [Month]" + " , ROUND(AVG(Availability),2) AS [Average]" + ", TOSTRING(ROUND(AVG(Availability),2)) + '%' AS [Label]" + ", CASE" + " WHEN AVG(Availability) <= 85 THEN '#950000'" + " WHEN AVG(Availability) < 90 THEN '#FEC405'" + " ELSE '#B8D757'" + " END AS [State]" + " FROM Orion.ResponseTime" + " WHERE (YEARDIFF(DATETIME,(GETUTCDATE()))=0)" + " GROUP BY DATETRUNC('MONTH',DATETIME)" + " ORDER BY DATETRUNC('MONTH',DATETIME) ASC"; // Convert the above query into a single line and add any parameters (required by the SolarWinds Information Service, even if empty) var dataToSendToSwis = JSON.stringify({ query: swql, parameters: {} }); // using jQuery make a call to the Orion Information Service $.ajax({ type: 'POST', url: '/Orion/Services/Information.asmx/QueryWithParameters', data: dataToSendToSwis, contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { console.log(response.d.Rows); google.charts.load("current", { packages: ['corechart'] }); google.charts.setOnLoadCallback(drawChart); function drawChart() { // Build a new dataTable to hold the results of the query var dataTable = new google.visualization.DataTable(); // Define the headings dataTable.addColumn({ type: 'string', id: 'Month' }); dataTable.addColumn({ type: 'number', id: 'Average' }); dataTable.addColumn({ type: 'string', role: 'annotation' }); dataTable.addColumn({ type: 'string', role: 'style' }); // Convert the results to a row and add them to the dataTable by cycleing through each record for (var i = 0; i < response.d.Rows.length; i++) { var row = [response.d.Rows[i][0], response.d.Rows[i][1], response.d.Rows[i][2], response.d.Rows[i][3]]; dataTable.addRow(row); console.log(response.d.Rows); } // end of datatable loop // define the options (title, height in pixels, etc.) var options = { title: 'Monthly Availability (Last 6 Months)', height: 450, bars: 'vertical', legend: { position: "none" }, }; //end of chart options // the "columnchart_monthly" is the ID of the
element we'll be replacing var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_monthly")); chart.draw(dataTable, options); } } }) </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant