granfana usage

5  grafana  add to ngix

  grafana  修改如图   

[server]
# Protocol (http, https, h2, socket)
protocol = http

# The ip address to bind to, empty will bind to all interfaces
http_addr =

# The http port to use
http_port = 3000

# The public facing domain name used to access grafana from a browser default is localhost
domain = 172.16.2.68

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
enforce_domain = false

# The full public facing url root_url = %(protocol)s://%(domain)s:%(http_port)s/
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana

# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
serve_from_sub_path = true

 

ngix 修改如图

    

location /grafana/ {
proxy_http_version 1.1;
proxy_pass http://172.16.2.68:3000/;

 

这个当我们访问   http://47.93.45.142:8094/grafana/   的时候可以访问到  grafana了

 

4. text panel user js 

   grafana text panel not support js by default. if you want to use it you must set disable_sanitize_html=true in config file 

1  Access in IIS

 

 

2 Not need login to access dashboard

 If we need access dashboard without login. We can set file (/Confs/default). Modify 

[auth.anonymous]
enabled = true
We can view dashboard ,And can't to edit dashboard.

3 third part authentic  

  A default.ini setting 

   

[auth.generic_oauth]
name = OAuth
enabled = true
allow_sign_up = true
client_id = some_id
client_secret = some_secret
scopes = openid email nickname
email_attribute_name = email:primary
auth_url =http://192.168.157.135:50108/login.aspx
token_url =http://192.168.157.135:50108/oauth.aspx
api_url =http://192.168.157.135:50108/get.aspx
team_ids =
allowed_organizations =
tls_skip_verify_insecure = false
tls_client_cert =
tls_client_key =
tls_client_ca =
send_client_credentials_via_post = false

   B authentic code 

       login.aspx

              

protected void Button1_Click(object sender, EventArgs e)
{
Response.SetCookie(new HttpCookie("user_email", "aaaaa@aaaaa.com"));
Response.Redirect("http://192.168.157.135:3000/login/generic_oauth?state=" + Request.QueryString["state"] + "&code=cc536d98d27750394a87ab9d057016e636a8ac31");
}

       oauth.aspx

       

protected void Page_Load(object sender, EventArgs e)
{
var a = new
{
access_token = "d50d9fd00acf797ac409d5890fcc76669b727e63",
token_type = "Bearer",
expiry_in = "1295998",
refresh_token = "TZzj2yvtWlNP6BvG6UC5UKHXY2Ey6eEo80FSYax6Yv8"
};
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
Response.Write(serializer.Serialize(a));
}

      get.aspx 

protected void Page_Load(object sender, EventArgs e)
{
var a = new
{
userId=1,
name = "Manivannan",
username = "ManivannanName",
email = "aaaaa@aaaaa.com",

};
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
Response.Write(serializer.Serialize(a));

}

   原理

                     grafana                                                                                             authentic server

                   1.invoke thirdpart login page,para has state                              

                                                                                                                              2.click login 。redirect granfa url with parameter  state and code(authentic generate)

                   3. invoke authentic server with code ,in order to get access token   

                                                                                                                             4 return access token

                   5 get user information from authentic server with access token     

                                                                                                                             6 return user information

 

   




posted on 2019-10-14 10:29  developer1980  阅读(197)  评论(0)    收藏  举报

导航