无法用石墨配置长颈鹿

时间:2013-12-20 18:14:23

标签: graphite giraffe.js

我正在尝试用石墨配置长颈鹿(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地址。如果没有别的办法,我可以尝试更改服务器的主机名。感谢。

服务器{## giraffe前端石墨         听86;         听[::]:86; ## ipv6only = on;         server_name长颈鹿;         root / opt / graphite / webapp / giraffe-master /;         index index.html index.htm;         每个服务器## logging         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 个答案:

答案 0 :(得分:2)

我是长颈鹿的创造者。希望我能帮忙。

我注意到的第一件事是您将graphite_url配置为指向0.0.0.0:8080。这一定是不正确的。由于Giraffe是基于javascript的,它在客户端上运行,因此地址应该是石墨服务器的外部IP / FQDN。

此外,如果您想在与石墨相同的服务器上运行Giraffe,最简单的方法是将长颈鹿文件放在与石墨相同的文件夹结构下,并确保您的网络服务器指向它。

例如,在我们的设置中,我已将长颈鹿文件放在/opt/graphite/webapp/giraffe中,然后在我们的nginx配置中将文档根设置为root /opt/graphite/webapp(如果您使用的是Apache,则可以执行同样使用DocumentRoot我相信。)

然后你应该能够在同一个地址/端口上访问石墨和长颈鹿,这也会为你删除任何跨域问题。然后,您无需在不同的端口上运行它。

干杯 约阿夫

答案 1 :(得分:1)

我使用apache2 webserver,我在/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";