MacroPower / macropower-analytics-panel

It's like Google Analytics, but for Grafana dashboards!
https://grafana.com/grafana/plugins/macropower-analytics-panel
GNU General Public License v2.0
27 stars 7 forks source link

Problem in Config #1

Closed aerosadegh closed 4 years ago

aerosadegh commented 4 years ago

Hi I want to use the plugin but, I cann't Config that.

I use Telegraf plugin http_listener_v2 on my server that grafana also was placed on it.

That Telegraf plugin was receives data and worked properly but this plugin seems don't send any data.

Please help me to fix this problem. Thanks a lot.

MacroPower commented 4 years ago

Hey, could you please try placing an analytics panel on a dashboard and loading it with a network inspector open to see if a request is being attempted?

Using the http_listener is smart but I'm not sure if the JSON data_format will work with the output I'm sending. I might give it a try later this week to see if I can get something working, but I think I will need to change the returned object structure.

aerosadegh commented 4 years ago

Thank you again.

I check Console in the Inspect Element:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://example.com:8080/telegraf. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://example.com:8080/telegraf. (Reason: CORS request did not succeed). Can I fix this problem or you must change something in your plugin?

Exactly! Your data structure needs to change for me. When I try to Inject your JSON data-format to InfluxDB , I missed data in "user" field and some other keys. Could you consider a suitable "line protocol" or other data_format to your plugin?

MacroPower commented 4 years ago

Hello @aerosadegh , sorry this took so long. I've just updated the plugin to support Grafana 7, and while I was at it I flattened the output object. This is what the JSON looks like now:

{
 "server": "http://example.com:8080/telegraf",
 "description": "new-dashboard-copy",
 "key": "fCZ4jTmMk",
 "hidden": false,
 "postEnd": true,
 "host": "localhost:3000",
 "update": "",
 "isSignedIn": true,
 "id": 1,
 "login": "admin",
 "email": "admin@localhost",
 "name": "admin",
 "lightTheme": false,
 "orgCount": 1,
 "orgId": 1,
 "orgName": "Main Org.",
 "orgRole": "Admin",
 "isGrafanaAdmin": true,
 "gravatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56",
 "timezone": "browser",
 "locale": "en-US",
 "helpFlags1": 0,
 "hasEditPermissionInFolders": true,
 "time": 1591727672
}

I'm working on getting together an example Telegraf config to include as well :)

MacroPower commented 4 years ago

Hello again,

I have added an example telegraf config in a new "example" directory, click here. Please feel free to play around with the options. I have the output set to file, just so it's a bit easier to test:

image

I also added a new option in the plugin's settings to disable cors, but I recommend that you instead solve the problem via putting telegraf behind a reverse proxy with proper certs.

The new version is not on the plugin repo yet, but you can manually grab it here: https://github.com/MacroPower/macropower-analytics-panel/releases/tag/v0.0.3

MacroPower commented 4 years ago

Telegraf support is now included in the official release https://grafana.com/grafana/plugins/macropower-analytics-panel

Please open another issue if you have any problems or questions!