2013-12-20 73 views
0

我想用石墨配置長頸鹿(0.9.10)。 Graphite在8080端口上運行成功,我能夠在端口9000上運行長頸鹿。我曾嘗試在長頸鹿中配置dashboards.js以指向石墨內的測試指標(foo.bar.bz),但我沒有看到任何圖表該指標的長頸鹿(僅在石墨中)。我最有可能配置錯誤dashboards.js - 任何建議解決/疑難解答這將不勝感激。無法配置石墨長頸鹿

更新: 的JSONP嘗試配置錯誤 - 我在瀏覽器控制檯中看到的錯誤如下(不匹配dashboards.js的當前版本,我在服務器上):

http://localhost:9000/graphite/render?from=-10minutes&&target=foo.bar.bz&ma…&format=json&jsonp=jQuery1830533570789033547_1387578768576&_=1387578768732 

dashboards.js

var graphite_url = "0.0.0.0:8080"; 

var dashboards = 
[ 
    { "name": "foo.bar.bz", // give your dashboard a name (required!) 
    "refresh": 5000, // each dashboard has its own refresh interval (in ms) 
    // add an (optional) dashboard description. description can be written in markdown/html. 
    "description": "foo.bar.bz test" , 
    "metrics": // metrics is an array of charts on the dashboard 
    [ 
     { 
     "alias": "foo.bar.bz", // display name for this metric 
     "target": "foo.bar.bz", // enter your graphite barebone target expression here 
     "description": "New test", // enter your metric description here 
     "summary": "sum", // available options: [sum|min|max|avg|last|<function>] 
     "summary_formatter": d3.format(",f") // customize your summary format function. see d3 formatting docs for more options 
     }, 
     { 
     "alias": "signup breakdown", 
     "targets": ["sumSeries(enter.your.graphite.metrics.here)", // targets array is also supported 
        "sumSeries(enter.another.graphite.metrics)"], // see below for more advanced usage 
     "description": "signup breakdown based on site location", 
     "renderer": "area", // use any rickshaw-supported renderer 
     "unstack": true // other parameters like unstack, interpolation, stroke, min, height are also available (see rickshaw documentation for more info) 
     }, 
     { 
     "alias": "Registration breakdown", 
     "target": "sumSeries(enter.your.graphite.metrics.here)", 
     // target can use a javascript function. This allows using dynamic parameters (e.g. period). See a few functions 
     // at the bottom of this file. 
     "target": function() { return 'summarize(events.registration.success,"' + entire_period() + 'min)' }, 
     "renderer": "bar", 
     "description": "Registrations based on channel", 
     "hover_formatter": d3.format("03.6g"), // customize your hover format 
     "null_as": 0 // null values are normally ignored, but you can convert null to a specific value (usually zero) 
     }, 
    ] 
    }, 
    { "name": "Visuals", 
    "refresh": 10000, 
    // you can use any rickshaw supported color scheme. 
    // Enter palette name as string, or an array of colors 
    // (see var scheme at the bottom). 
    // Schemes can be configured globally (see below), per-dashboard, or per-metric 
    "scheme": "classic9", // this is a dashboard-specific color palette 
    "description": "#Visual settings <img class='pull-right' src='img/giraffe.png' />", 
    "metrics": 
    [ 
     { 
     "alias": "network", 
     "target": "aliasByNode(derivative(servers.system.eth*),4)", 
     "events": "*", // instead of annotator, if you use the graphite events feature 
         // you can retrieve events matching specific tag(s) -- space separated 
         // or use * for all tags. Note you cannot use both annotator and events. 
     "description": "main system cpu usage on production (cardinal interpolation, line renderer, colspan=3)", 
     "interpolation": "linear", 
     "colspan": 3, 
     }, 
     { 
     "alias": "cpu utilization", 
     "target": "aliasByNode(derivative(servers.system.cpu.*),4)", // target can use any graphite-supported wildcards 
     "annotator": 'events.deployment', // a simple annotator will track a graphite event and mark it as 'deployment'. 
              // enter your graphite target as a string 
     "description": "cpu utilization on production (using linear interpolation). Summary displays the average across all series", 
     "interpolation": "linear", // you can use different rickshaw interpolation values 
     "stroke_width": 1, // change stroke width 
     "summary": "avg", 
     }, 
     { 
     "alias": "proc mem prod", 
     "targets": ["aliasByNode(derivative(servers.system.cpu.user),4)", // targets array can include strings, 
                      // functions or dictionaries 
        {target: 'alias(derivative(servers.system.cpu.system,"system utilization")', 
        alias: 'system utilization',       // if you use a graphite alias, specify it here 
        color: '#f00'}],          // you can also specify a target color this way 
                      // (note that these values are ignored on the demo) 
     // annotator can also be a dictionary of target and description. 
     // However, only one annotator is supported per-metric. 
     "annotator": {'target' : 'events.deployment', 
         'description' : 'deploy'}, 
     "description": "main process memory usage on production (different colour scheme and interpolation)", 
     "interpolation": "step-before", 
     "scheme": "munin", // this is a metric-specific color palette 
     }, 
     { 
     "alias": "sys mem prod", 
     "target": "aliasByNode(derivative(servers.system.cpu.*),4)", 
     "events": "*", // instead of annotator, if you use the graphite events feature 
         // you can retrieve events matching specific tag(s) -- space separated 
         // or use * for all tags. Note you cannot use both annotator and events. 
     "description": "main system memory usage on production (cardinal interpolation, line renderer)", 
     "interpolation": "cardinal", 
     "renderer": "line", 
     "max": 150, // you can specify max value for the y-axis 
     "min": 20, // and also min 
     }, 
    ] 
    }, 
    { "name": "Setup", 
    "refresh": 10000, 
    "scheme": "colorwheel", 
    "graphite_url": "demo", // you can override the default graphite_url with a dashboard-specific url 
    "description": "#Setup and configuration <img class='pull-right' src='img/giraffe.png' />" 
       +"\n" 
       +"\n##Installation" 
       +"\n" 
       +"\nTo install giraffe, simply [download](https://github.com/kenhub/giraffe/archive/master.zip) the code and run it from your browser." 
       +"\nYou can put it on any type of web server, and also open the `index.html` file from your local drive." 
       +"\n" 
       +"\n##Authentication" 
       +"\n" 
       +"\nGiraffe uses JSONP to retrieve the data from your graphite server. It should work out of the box, unless you" 
       +"\nhave setup authentication. Basic authentication seems to work in Firefox (it will prompt you), " 
       +"\nbut with Chrome you might need to authenticate to your graphite server first, and then access Giraffe." 
       +"\n" 
       +"\n##Configuration" 
       +"\n" 
       +"\nThe main configuration for all dashboards is found in `dashboards.js`. The file is reasonably self-explanatory, " 
       +"\nso please take a look." 
       +"\n" 
       +"\nIf you need to change the page layout, CSS, or add/remove a time period, you can also edit `index.html` and `css/main.css` file." 
       +"\n" 
       , 
    "metrics": 
    [ 
     { 
     "alias": "production HTTP req", 
     "target": "aliasByNode(derivative(servers.gluteus-medius.Http.http_response_rates.*),4)", 
     "renderer": "bar", 
     "interpolation": "cardinal", 
     "summary": "last", 
     }, 
    ] 
    }, 
]; 

var scheme = [ 
       '#423d4f', 
       '#4a6860', 
       '#848f39', 
       '#a2b73c', 
       '#ddcb53', 
       '#c5a32f', 
       '#7d5836', 
       '#963b20', 
       '#7c2626', 
       ].reverse(); 

function relative_period() { return (typeof period == 'undefined') ? 1 : parseInt(period/7) + 1; } 
function entire_period() { return (typeof period == 'undefined') ? 1 : period; } 
function at_least_a_day() { return entire_period() >= 1440 ? entire_period() : 1440; } 

更新:

我最初使用giraffe-web並使用nginx來代理對節點服務的請求。由於我暫時停止使用giraffe-web,我已經從nginx默認文件(下面複製的相關部分)中註釋掉了代理部分。我作爲一個單獨的服務器在端口86上運行 - 如果這是問題,我可以更改我的nginx conf文件。截至目前,長頸鹿webUI無法檢索到我試圖從石墨中檢索的測試指標(我可以在石墨中查看該指標圖表)。我已將dashboards.js更改爲運行該服務的IP地址。如果沒有其他工作,我可以嘗試更改服務器的主機名。謝謝。

服務器{##長頸鹿石墨前端 listen 86; listen [::]:86; ## ipv6only = on; server_name長頸鹿; root/opt/graphite/webapp/giraffe-master /; index index.html index.htm; ##每臺服務器的日誌記錄 access_log /var/log/nginx/giraffe/access.log; error_log /var/log/nginx/giraffe/error.log;

location/{ 
      #proxy_redirect off; 
      #proxy_set_header X-Real-IP $remote_addr; 
      #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      #proxy_set_header X-Forwarded-Proto $scheme; 
      #proxy_set_header Host $http_host; 
      #proxy_set_header X-Nginx-Proxy true; 
      #proxy_set_header Connection ""; 
      #proxy_http_version 1.1; 
      #proxy_set_header Host $host; ##removed the $http_host option 
      #proxy_pass http://giraffe; 
    } 

}

回答

2

我是長頸鹿的創造者。希望我能幫上忙。

我注意到的第一件事情是,您將graphite_url配置爲指向0.0.0.0:8080。這一定是不正確的。由於長頸鹿是基於JavaScript的,它運行在客戶端上,所以地址應該是石墨服務器的外部IP/FQDN。此外,如果您想要在與石墨相同的服務器上運行長頸鹿,最簡單的方法是將長頸鹿文件放置在與石墨相同的文件夾結構下,並確保您的Web服務器指向它。

例如,在我們的設置我已經把長頸鹿文件/opt/graphite/webapp/giraffe,然後在我們的nginx的配置設置文檔根目錄爲root /opt/graphite/webapp(如果你使用Apache,你可以做使用DocumentRoot同我相信)。

然後,您應該可以在同一地址/端口上同時訪問石墨和長頸鹿,這也將爲您解決任何跨域問題。然後您不需要在不同的端口上運行它。

乾杯 約阿夫

+0

感謝您回覆。我昨天試着在你的評論之前更改了網址,但由於某種原因,即使在我重新啓動/重新加載nginx(我很可能錯過了某些內容)之後,新網址並未被拾取。我將再次嘗試 - 並使用/ opt/graphite/webapps目錄中的長頸鹿目錄。一旦我取得進展或卡住,我會更新。再次感謝您的迴應。 –

+0

我不完全確定爲什麼,但即使我硬編碼了文件中的IP地址,dashboards.js文件仍然提到了localhost:8080。我正在使用長頸鹿網絡(節點)發射長頸鹿。 –

+0

我嘗試了沒有長頸鹿網絡節點服務的nginx路由。 JSONP調用仍然無效(URL現在是ip地址:nginx的監聽端口號/石墨端口號/ ...),這顯然是失敗的。 –

1

我用的Apache2 web服務器,我增加了一個別名爲我/etc/apache2/httpd.conf長頸鹿。

Alias /giraffe/ /home/vagrant/giraffe/ 

重新啓動Apache網絡服務器,它可作爲:

IP /長頸鹿/ index.html的。

http://graphite_url.com/giraffe/index.html

您的IP地址或FQDN您

其次取代石墨網址,你確定,如果你的碳守護進程正在運行?

註冊網址,

var graphite_url = "http://10.0.1.11"; 
+0

感謝分享 - 是的碳和石墨運行 - 我可以看到石墨圖表,但不是長頸鹿之一(也許我誤解了配置的某些方面)。現在,我正在使用nginx並可以訪問長頸鹿 - 只是圖表URL被錯誤配置,JSONP調用失敗。 –

+0

你可以使用tcpdump捕獲你的流量,並分享你看到的網址。一定要查詢正確的元素。 var cpu =「a.b.c.cpu」;並將其填充到儀表板中。 –

+0

我檢查了鉻工具 - 由於某種原因JSONP調用格式錯誤(例如x.x.x.x:86/x.x.x.x/....)。 IP地址被複制。我將很快發佈更多相關信息 - 今天我一直在對設置進行更改。 –