Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ceph osd_df to metricbeat #5606

Merged
merged 8 commits into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,85 @@ type: long
Last updated


[float]
== osd_df fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that popped up in my head is that we have here df and we have system.filesystem with similar info. Don't know if osd_filesystem would make sense here (even though pretty long).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the function of osd df in ceph is very similar with *system.filesystem * in linux. It shows osds' weight, reweight, size, used, avai and used pct information. Naming this new metricbet as osd_df is because it's a standard command in Ceph, and I consider that it will be much more familer to ceph users. For more about the command's detials:
http://docs.ceph.com/docs/master/man/8/ceph/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a similar discussion with the system module. Most sysadmins will be used to run the df command. But someone consuming the data is more looking for information about the filesystem which could be a different person. TBH don't know which one is better. I'm fine moving forward with df.


ceph osd disk usage information



[float]
=== `ceph.osd_df.id`

type: long

osd node id


[float]
=== `ceph.osd_df.name`

type: text

osd node name


[float]
=== `ceph.osd_df.device_class`

type: keyword

osd node type, illegal type include hdd, ssd etc.


[float]
=== `ceph.osd_df.total.byte`

type: long

format: bytes

osd disk total volume


[float]
=== `ceph.osd_df.used.byte`

type: long

format: bytes

osd disk usage volume


[float]
=== `ceph.osd_df.available.bytes`

type: long

format: bytes

osd disk available volume


[float]
=== `ceph.osd_df.pg_num`

type: long

shows how many pg located on this osd


[float]
=== `ceph.osd_df.used.pct`

type: scaled_float

format: percent

osd disk usage percentage


[float]
== osd_tree fields

Expand Down
4 changes: 4 additions & 0 deletions metricbeat/docs/modules/ceph.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ The following metricsets are available:

* <<metricbeat-metricset-ceph-monitor_health,monitor_health>>

* <<metricbeat-metricset-ceph-osd_df,osd_df>>

* <<metricbeat-metricset-ceph-osd_tree,osd_tree>>

* <<metricbeat-metricset-ceph-pool_disk,pool_disk>>
Expand All @@ -51,6 +53,8 @@ include::ceph/cluster_status.asciidoc[]

include::ceph/monitor_health.asciidoc[]

include::ceph/osd_df.asciidoc[]

include::ceph/osd_tree.asciidoc[]

include::ceph/pool_disk.asciidoc[]
Expand Down
23 changes: 23 additions & 0 deletions metricbeat/docs/modules/ceph/osd_df.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-metricset-ceph-osd_df]]
=== Ceph osd_df metricset

experimental

include::../../../module/ceph/osd_df/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-ceph,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/ceph/osd_df/_meta/data.json[]
----
1 change: 1 addition & 0 deletions metricbeat/include/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
_ "github.com/elastic/beats/metricbeat/module/ceph/cluster_health"
_ "github.com/elastic/beats/metricbeat/module/ceph/cluster_status"
_ "github.com/elastic/beats/metricbeat/module/ceph/monitor_health"
_ "github.com/elastic/beats/metricbeat/module/ceph/osd_df"
_ "github.com/elastic/beats/metricbeat/module/ceph/osd_tree"
_ "github.com/elastic/beats/metricbeat/module/ceph/pool_disk"
_ "github.com/elastic/beats/metricbeat/module/couchbase"
Expand Down
51 changes: 51 additions & 0 deletions metricbeat/module/ceph/_meta/testdata/osd_df_sample_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"output": {
"nodes": [
{
"crush_weight": 0.048691,
"depth": 2,
"device_class": "hdd",
"id": 0,
"kb": 52325356,
"kb_avail": 51245860,
"kb_used": 1079496,
"name": "osd.0",
"pgs": 0,
"pool_weights": {},
"reweight": 1.0,
"type": "osd",
"type_id": 0,
"utilization": 2.063046,
"var": 1.0
},
{
"crush_weight": 0.048691,
"depth": 2,
"device_class": "hdd",
"id": 1,
"kb": 52325356,
"kb_avail": 51245860,
"kb_used": 1079496,
"name": "osd.1",
"pgs": 0,
"pool_weights": {},
"reweight": 1.0,
"type": "osd",
"type_id": 0,
"utilization": 2.063046,
"var": 1.0
}
],
"stray": [],
"summary": {
"average_utilization": 2.063046,
"dev": 0.0,
"max_var": 1.0,
"min_var": 1.0,
"total_kb": 104650712,
"total_kb_avail": 102491720,
"total_kb_used": 2158992
}
},
"status": "OK"
}
31 changes: 31 additions & 0 deletions metricbeat/module/ceph/osd_df/_meta/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"@timestamp": "2017-11-16T02:30:32.779Z",
"@metadata": {
"beat": "metricbeat",
"type": "doc",
"version": "7.0.0-alpha1"
},
"ceph": {
"osd_df": {
"device_class": "hdd",
"name": "osd.1",
"total_byte": 52325356,
"used_byte": 1079496,
"avail_byte": 51245860,
"pg_num": 0,
"used_pct": 0.020630456866839092,
"id": 1
}
},
"metricset": {
"module": "ceph",
"name": "osd_df",
"host": "192.168.56.131:5000",
"rtt": 5452
},
"beat": {
"name": "centos7gui",
"hostname": "centos7gui",
"version": "7.0.0-alpha1"
}
}
3 changes: 3 additions & 0 deletions metricbeat/module/ceph/osd_df/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
=== Ceph cluster_health metricset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this title can now be removed with our new script. Sorry missed that previously but realised it now that i checked out the branch locally.


This is the `osd_df` metricset of the Ceph module.
41 changes: 41 additions & 0 deletions metricbeat/module/ceph/osd_df/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
- name: osd_df
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left the comments in the fields.asciidoc, but they should obviously go here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it. :)

type: group
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a new feature I just added recently. Could you add release: experimental here? Like this you don't have to add it manually to the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will add it.

description: >
ceph osd disk usage information
fields:
- name: id
type: long
description: >
osd node id
- name: name
type: text
description: >
osd node name
- name: device_class
type: keyword
description: >
osd node type, illegal type include hdd, ssd etc.
- name: total.byte
type: long
format: bytes
description: >
osd disk total volume
- name: used.byte
type: long
format: bytes
description: >
osd disk usage volume
- name: available.bytes
type: long
format: bytes
description: >
osd disk available volume
- name: pg_num
type: long
description: >
shows how many pg located on this osd
- name: used.pct
type: scaled_float
format: percent
description: >
osd disk usage percentage
62 changes: 62 additions & 0 deletions metricbeat/module/ceph/osd_df/data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package osd_df

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use an underscore in package name


import (
"encoding/json"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
)

type Node struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type Node should have comment or be unexported

ID int64 `json:"id"`
Name string `json:"name"`
Used int64 `json:"kb_used"`
Available int64 `json:"kb_avail"`
Total int64 `json:"kb"`
PgNum int64 `json:"pgs"`
DeviceClass string `json:"device_class"`
}

type Output struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type Output should have comment or be unexported

Nodes []Node `json:"nodes"`
}

type OsdDfRequest struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type OsdDfRequest should have comment or be unexported

Status string `json:"status"`
Output Output `json:"output"`
}

func eventsMapping(content []byte) ([]common.MapStr, error) {
var d OsdDfRequest
err := json.Unmarshal(content, &d)
if err != nil {
logp.Err("Error: ", err)
return nil, err
}

nodeList := d.Output.Nodes

//osd node list
events := []common.MapStr{}
for _, node := range nodeList {
nodeInfo := common.MapStr{
"id": node.ID,
"name": node.Name,
"total.byte": node.Total,
"used.byte": node.Used,
"available.byte": node.Available,
"device_class": node.DeviceClass,
"pg_num": node.PgNum,
}

if 0 != node.Total {
var usedPct float64
usedPct = float64(node.Used) / float64(node.Total)
nodeInfo["used.pct"] = usedPct
}

events = append(events, nodeInfo)
}

return events, nil
}
58 changes: 58 additions & 0 deletions metricbeat/module/ceph/osd_df/osd_df.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package osd_df

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use an underscore in package name


import (
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/cfgwarn"
"github.com/elastic/beats/metricbeat/helper"
"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/mb/parse"
)

const (
defaultScheme = "http"
defaultPath = "/api/v0.1/osd/df"
)

var (
hostParser = parse.URLHostParserBuilder{
DefaultScheme: defaultScheme,
DefaultPath: defaultPath,
}.Build()
)

func init() {
if err := mb.Registry.AddMetricSet("ceph", "osd_df", New, hostParser); err != nil {
panic(err)
}
}

type MetricSet struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type MetricSet should have comment or be unexported

mb.BaseMetricSet
*helper.HTTP
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported function New should have comment or be unexported

cfgwarn.Beta("The ceph osd_df metricset is experimental")

http := helper.NewHTTP(base)
http.SetHeader("Accept", "application/json")

return &MetricSet{
base,
http,
}, nil
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method MetricSet.Fetch should have comment or be unexported

content, err := m.HTTP.FetchContent()
if err != nil {
return nil, err
}

events, err := eventsMapping(content)
if err != nil {
return nil, err
}

return events, nil
}
Loading