Grafana docker path


#1

Hi,

I install grafana via docker like this:

 docker run -d \
           -h grafana-local.pop-sc.rnp.br \
           -p 3000:3000 \
           -e "GF_SERVER_ROOT_URL=http://grafana-local.pop-sc.rnp.br" \
           -e "GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource,raintank-worldping-app,grafana-piechart-panel,grafana-worldmap-panel,kentik-app,grafana-example-app" \
           --name=grafana \

So, in my query.options.html page I have created a new form and a submit button. When I click submit I do an AJAX post using JQuery. Where in my grafana container I should put my index.html file, to send data in post request to that file for example?

Something like this:

$.ajax({
	type: "POST",
	crossDomain: true,
	url: 'http://grafana-local.pop-sc.rnp.br:3000/index.html',
	data: myData,
	dataType: 'json',
	success: function( response ){
		alert("posted in 'http://grafana-local.pop-sc.rnp.br:3000/index.html' "); 
	},
	error: function( error ){
	    alert( error );
	}
});

#2

What are you trying to do? Grafana is an angular app so if you want to add files to it, you will have to do some programming.


#3

I add another form to that page, and I wanna post these datas collected in that page to a python script. Then, my python script do the necessaries queries and package them in that format :

[
  {
    "target":"metricOne",
    "datapoints":[
      [622,1450754160000],
      [365,1450754220000]
    ]
  },
  {
    "target":"metricTwo",
    "datapoints":[
      [861,1450754160000],
      [767,1450754220000]
    ]
  }
]  

to be returned in query() function in my datasource.js


#4

At first, I tried to edit the query page in grafana to add another metrics field and chain them. But I did not found the code file to do that, so I just build my form in the query.options.html below that code :

<section class="grafana-metric-options" >
	<div class="gf-form"> 
		TESTING
	</div>
</section>

#5

Which version of Angular Grafana was building?


#6

If you want to do this properly, then you should fork Grafana, build it from source and make your docker image.

The instructions for building Grafana can be found here:

http://docs.grafana.org/project/building_from_source/#building-grafana-from-source

I really wouldn’t recommend it but if that is too hard for you then you can try changing the compiled files in the docker image. Grafana is mostly written in TypeScript and the build process compiles the files into generated JavaScript files that are hard to read.

This describes where all the files are located: http://docs.grafana.org/installation/debian/#package-details

Grafana is built with Angular 1.6.1.