我有问题让grafana从石墨获得指标。似乎错误来自石墨本身,需要 graphite-api 。
我是否绝对需要安装并运行 graphite-api 来完成这项工作?
感谢您的帮助。
使用curl我可以获取所有指标树,但浏览器仍然给我一个指标查询失败错误。可能是我应该在这里复制并粘贴我的所有配置。
graphite nginx conf:
server {
listen 443;
ssl on;
ssl_certificate /etc/pki/tls/certs/dev.mydomain.net.crt;
ssl_certificate_key /etc/pki/tls/certs/dev.mydomain.net.key;
server_name graphite.mydomain.net;
#charset koi8-r;
rewrite_log off;
access_log /srv/www/graphite/access.log main;
error_log /srv/www/graphite/error.log debug;
# Proxy to Uchiwa on localhost:3000
#
location / {
proxy_pass http://graphite:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
if ($http_origin ~* "^http://metro.mydomain.net:80$"){
set $cors "true";
}
if ($request_method = 'OPTIONS') {
set $cors "${cors}options";
}
if ($request_method = 'GET') {
set $cors "${cors}get";
}
if ($request_method = 'POST') {
set $cors "${cors}post";
}
if ($cors = 'true') {
add_header "Access-Control-Allow-Origin" "$http_origin";
add_header "Access-Control-Allow-Credentials" "true";
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS";
add_header "Access-Control-Allow-Headers" "Authorization, origin, accept";
}
if ($cors = "trueoptions") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($cors = "truepost") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($cors = "trueget") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
}
grafana nginx conf:
server {
#listen 443;
listen 80;
#ssl on;
#ssl_certificate /etc/pki/tls/certs/dev.mydomain.net.crt;
#ssl_certificate_key /etc/pki/tls/certs/dev.mydomain.net.key;
server_name metro.mydomain.net;
root /var/www/html/grafana;
index index.html
client_max_body_size 30M;
#charset koi8-r;
rewrite_log off;
access_log /var/www/html/grafana.access.log main;
error_log /var/www/html/grafana.error.log debug;
}
grafana config.js:
// Graphite & Elasticsearch example setup
datasources: {
graphite: {
default: true,
type: 'graphite',
url: "http://graphite.mydomain.net:8000",
render_method: 'GET',
},
/* elasticsearch: {
type: 'elasticsearch',
url: "http://my.elastic.server.com:9200",
index: 'grafana-dash',
grafanaDB: true,
}*/
},
我无法在此处复制和粘贴日志,因为它们包含链接,并且网站告诉我应该至少有10个声誉来发布超过2个链接。虽然它们不是真正的链接,只是我服务器上的网址,而且我不知道如何以纯文本格式转换它们以便我可以发布。然后我不得不删除所有日志消息以编辑我的问题。
请帮帮我????
感谢。
问候
答案 0 :(得分:1)
我没有更新帖子。我成功地用石墨网建立了我的grafana ui。问题是它不可能使用跨域与js,我的浏览器(客户端)与我的grafana / graphite不在同一台机器上。 我所做的是将grafana url本身放在config.js的数据源中,并将其本地重定向到我的本地石墨域。这是我的nginx和grafana / graphite配置:
graphite nginx conf:
server {
listen 443;
ssl on;
ssl_certificate /etc/pki/tls/certs/dev.mydomain.net.crt;
ssl_certificate_key /etc/pki/tls/certs/dev.mydomain.net.key;
server_name graphite.mydomain.net;
#charset koi8-r;
rewrite_log off;
access_log /srv/www/graphite/access.log main;
error_log /srv/www/graphite/error.log debug;
#
location / {
proxy_pass http://graphite:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
if ($http_origin ~* "^https://metro.mydomain.net:443$"){
set $cors "true";
}
if ($request_method = 'OPTIONS') {
set $cors "${cors}options";
}
if ($request_method = 'GET') {
set $cors "${cors}get";
}
if ($request_method = 'POST') {
set $cors "${cors}post";
}
if ($cors = 'true') {
add_header "Access-Control-Allow-Origin" "$http_origin";
add_header "Access-Control-Allow-Credentials" "true";
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS";
add_header "Access-Control-Allow-Headers" "Authorization, origin, accept";
}
if ($cors = "trueoptions") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($cors = "truepost") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($cors = "trueget") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
}
grafana nginx conf:
server {
listen 443;
ssl on;
ssl_certificate /etc/pki/tls/certs/dev.mydomain.net.crt;
ssl_certificate_key /etc/pki/tls/certs/dev.mydomain.net.key;
server_name metro.mydomain.net;
root /var/www/html/grafana;
index index.html
client_max_body_size 30M;
#charset koi8-r;
rewrite_log off;
access_log /var/www/html/grafana.access.log main;
error_log /var/www/html/grafana.error.log debug;
location /render {
proxy_pass http://graphite:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /metric {
proxy_pass http://graphite:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
grafana config.js:
// Graphite & Elasticsearch example setup
datasources: {
graphite: {
default: true,
type: 'graphite',
url: "https://metro.mydomain.net",
render_method: 'GET',
},
/* elasticsearch: {
type: 'elasticsearch',
url: "http://my.elastic.server.com:9200",
index: 'grafana-dash',
grafanaDB: true,
}*/
},
请注意,在这里,我可以通过localhost在我的网址中替换石墨,它仍然有效。
现在我可以创建并保存我的图表
希望这会有助于其他面对grafana设置的人。
此致