-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Adding HAProxy module #2384
Adding HAProxy module #2384
Changes from 1 commit
8c236c4
5b4adac
056f7f8
7b4c97d
8d9d696
dcf16a8
16dafbe
ac6dbe1
543319e
52652bf
eb7c22d
6c0eb6f
e2828a8
3e4384e
004d9fa
007d4a4
ef9c877
498ada4
e989718
41eb385
607c564
6ba4fbd
e768cd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ build | |
/metricbeat | ||
/metricbeat.test | ||
/docs/html_docs | ||
/logs/* | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
FROM haproxy:1.6 | ||
COPY haproxy.conf /usr/local/etc/haproxy/haproxy.cfg | ||
COPY ./haproxy.conf /usr/local/etc/haproxy/haproxy.cfg |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,7 +132,7 @@ type Info struct { | |
|
||
// Client is an instance of the HAProxy client | ||
type Client struct { | ||
connection net.Conn | ||
//connection net.Conn | ||
Address string | ||
ProtoScheme string | ||
} | ||
|
@@ -163,16 +163,17 @@ func (c *Client) run(cmd string) (*bytes.Buffer, error) { | |
if err != nil { | ||
return response, err | ||
} | ||
c.connection = conn | ||
//c.connection = conn | ||
|
||
defer c.connection.Close() | ||
//defer c.connection.Close() | ||
defer conn.Close() | ||
|
||
_, err = c.connection.Write([]byte(cmd + "\n")) | ||
_, err = conn.Write([]byte(cmd + "\n")) | ||
if err != nil { | ||
return response, err | ||
} | ||
|
||
_, err = io.Copy(response, c.connection) | ||
_, err = io.Copy(response, conn) | ||
if err != nil { | ||
return response, err | ||
} | ||
|
@@ -185,13 +186,14 @@ func (c *Client) run(cmd string) (*bytes.Buffer, error) { | |
} | ||
|
||
// GetStat returns the result from the 'show stat' command | ||
func (c *Client) GetStat() (statRes []*Stat, err error) { | ||
func (c *Client) GetStat() ([]*Stat, error) { | ||
|
||
runResult, err := c.run("show stat") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var statRes []*Stat | ||
csvReader := csv.NewReader(runResult) | ||
csvReader.TrailingComma = true | ||
|
||
|
@@ -205,7 +207,7 @@ func (c *Client) GetStat() (statRes []*Stat, err error) { | |
} | ||
|
||
// GetInfo returns the result from the 'show stat' command | ||
func (c *Client) GetInfo() (infoRes *Info, err error) { | ||
func (c *Client) GetInfo() (*Info, error) { | ||
|
||
res, err := c.run("show info") | ||
if err != nil { | ||
|
@@ -234,7 +236,7 @@ func (c *Client) GetInfo() (infoRes *Info, err error) { | |
var result *Info | ||
err := mapstructure.Decode(resultMap, &result) | ||
if err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider writing this which is slightly more concise. (not a mandatory change, it's just how I'd of written it)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I definitely agree it's cleaner that way, I'll definitely change that. |
||
panic(err) | ||
return nil, err | ||
} | ||
return result, nil | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,191 +4,193 @@ | |
General infomration collected on HAProxy process | ||
fields: | ||
- name: nb_proc | ||
type: intger | ||
type: integer | ||
description: > | ||
Number of processes | ||
|
||
- name: process_num | ||
type: intger | ||
type: integer | ||
description: > | ||
Process number | ||
|
||
- name: pid | ||
type: intger | ||
type: integer | ||
description: > | ||
Process ID | ||
|
||
- name: uptime_sec | ||
type: intger | ||
type: integer | ||
description: > | ||
Current uptime in seconds | ||
|
||
- name: mem_max_mb | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider reporting this field as bytes rather than MB. Then you can apply a bytes field formatter so that Kibana renders the value nicely. If you do change it to bytes, then add |
||
type: intger | ||
type: integer | ||
format: bytes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the value is actually in MB then you don't want to format it as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see you do convert the value. So then I think the field just needs a rename to reflect the correct units. |
||
description: > | ||
Max number of memory usage in MB | ||
|
||
- name: ulimit_n | ||
type: intger | ||
type: integer | ||
description: > | ||
Max number of open files for process | ||
|
||
- name: max_sock | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: max_conn | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: hard_max_conn | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: curr_conns | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: cum_conns | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: cum_req | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: max_ssl_conns | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: curr_ssl_conns | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: cum_ssl_conns | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: max_pipes | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: pipes_used | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: pipes_free | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: conn_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: conn_rate_limit | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: max_conn_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: sess_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: sess_rate_limit | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: max_sess_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_rate_limit | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: max_ssl_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_frontend_key_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_frontend_max_key_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_frontend_session_reuse_pct | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_babckend_key_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_frontend_key_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_frontend_max_key_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_frontend_session_reuse_pct | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_babckend_key_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_backend_max_key_rate | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_cached_lookups | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: ssl_cache_misses | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: compress_bps_in | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: compress_bps_out | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: compress_bps_rate_limit | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: zlib_mem_usage | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: max_zlib_mem_usage | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: tasks | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: run_queue | ||
type: intger | ||
type: integer | ||
description: > | ||
|
||
- name: idle_pct | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider making this value range on [0, 1] so you can use a float with a percentage formatter. For example: https://github.com/elastic/beats/blob/master/metricbeat/module/system/memory/_meta/fields.yml#L26-L27 |
||
type: intger | ||
type: scaled_float | ||
format: percent | ||
description: > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be not needed anymore as soon as this is rebased on top of master or master is merged.