Rust riemann client

23 views
Skip to first unread message

Sanchayan Maity

unread,
Dec 9, 2017, 9:20:05 AM12/9/17
to Rust Bangalore Community
Hi,

There is a rust riemann client available
https://github.com/borntyping/rust-riemann_client

This seems to not implement the attributes property of an event. See the proto description below for event
https://github.com/borntyping/rust-riemann_client/blob/master/src/proto/mod.proto
From what I understand, riemann server understands this proto implementation. You just can't send anything over gRPC.

The idea I had in mind was to use this client and implement whatever is missing. Once the client is complete (it is already capable of sending events) we can use this as library crate for all monitoring agents we want to write. The monitoring agents will only collect information and this client library can be used to send event streams to Riemann.

Raj and me were looking into this. I am not sure if my idea is correct. Others are welcome to look into this.

Regards,
Sanchayan.

Sanchayan Maity

unread,
Dec 9, 2017, 5:39:57 PM12/9/17
to Rust Bangalore Community

Below is the git diff of my changes. I guess it works.
diff --git a/src/main.rs b/src/main.rs
index dbf3bef..c5d2ff1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,6 +11,8 @@ extern crate protobuf;
extern crate riemann_client;
extern crate rustc_serialize;

+use riemann_client::proto::Attribute;
+
static USAGE: &'static str = "
Usage: riemann_cli [-HP] send [options]
riemann_cli [-HP] query <query>
@@ -89,7 +91,16 @@ fn main() {
}

if !args.flag_attribute.is_empty() {
- unimplemented!();
+ let mut vec_attr: Vec<Attribute> = Vec::new();
+ let mut args_attr: Vec<String> = args.flag_attribute;
+ for attr in args_attr.iter_mut() {
+ let mut res: Vec<String> = attr.split("=").map(|s| s.to_string()).collect();
+ let mut at = riemann_client::proto::Attribute::new();
+ if let Some(x) = res.pop() { at.set_value(x) };
+ if let Some(x) = res.pop() { at.set_key(x) };
+ vec_attr.push(at);
+ }
+ event.set_attributes(protobuf::RepeatedField::from_vec(vec_attr));
}

println!("--> {{ {:?} }}", event);

From riemann-health
#riemann.codec.Event{:host "sanchayan-arch", :service "load", :state "ok", :description "1-minute load average/core is 0.2075", :metric 0.2075, :tags ["sanchayan"], :time 1512858320, :ttl 10.0, :fosscafe "hello"}

From rust riemann client
#riemann.codec.Event{:host "sanchayan-arch", :service "riemann_cli", :state "ok", :description nil, :metric 11.0, :tags ["sanchayan"], :time 1.512858508201E9, :ttl nil, :fosscafe "hello"}

The last part of putting in an attribute for the event was added to the main code. I was wrong in assuming that the attributes property of the event is not implemented. It is implemented using set_attributes method, only that the cli client never parsed it from command line.

This crate should be usable to send the "event" stream by allowing us to set any set any of the fields in the "event" as defined by the proto and then sending it using the tcp transport layer implementation of the crate.

I guess what remains is the implementation of data parsers for whatever data we want to send to riemann for example, in case of riemann-health for CPU load we would parse /proc/stat.

Regards,
Sanchayan.

Raj Kiran Gade

unread,
Dec 9, 2017, 6:08:47 PM12/9/17
to rus...@googlegroups.com
Cool buddy. Will look into parsing as well. 

Regards,
Raj Kiran Gade 

--
https://meetup.com/rustox
---
You received this message because you are subscribed to the Google Groups "Rust Bangalore Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rustox+un...@googlegroups.com.
To post to this group, send email to rus...@googlegroups.com.
Visit this group at https://groups.google.com/group/rustox.
To view this discussion on the web visit https://groups.google.com/d/msgid/rustox/76bd544f-d406-44cb-b908-962c82e1d416%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Regards,
Raj Kiran Gade

Raj Kiran Gade

unread,
Dec 9, 2017, 8:24:45 PM12/9/17
to rus...@googlegroups.com
Hello Team,

Found a crate "sys-info" for pulling up sys health.
Used sysinfo and riemann_client to pull boottime of machine and send it as an event to riemann.

Reimann Log on Console.

#riemann.codec.Event{:host "hydrogen", :service "boottime", :state "OK", :description nil, :metric 5154.0, :tags nil, :time 1.512866612126E9, :ttl nil}
#riemann.codec.Event{:host "hydrogen", :service "boottime", :state "OK", :description nil, :metric 6410.0, :tags nil, :time 1.512867867424E9, :ttl nil}


@Sanchayan,
getting few errors in adding attributes programatically. Currently using your compiled crate. Will check this out today.



Regards,
Raj Kiran Gade
--
https://meetup.com/rustox
---
You received this message because you are subscribed to the Google Groups "Rust Bangalore Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rustox+un...@googlegroups.com.
To post to this group, send email to rus...@googlegroups.com.
Visit this group at https://groups.google.com/group/rustox.
To view this discussion on the web visit https://groups.google.com/d/msgid/rustox/76bd544f-d406-44cb-b908-962c82e1d416%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saifi

unread,
Dec 9, 2017, 10:15:54 PM12/9/17
to Rust Bangalore Community
On Sat, 9 Dec 2017, Sanchayan Maity wrote:

> On Saturday, December 9, 2017 at 7:50:05 PM UTC+5:30, Sanchayan Maity wrote:
>>
>> There is a rust riemann client available
>> https://github.com/borntyping/rust-riemann_client
>>
>> This seems to not implement the attributes property of an event. See the proto description below for event
>> https://github.com/borntyping/rust-riemann_client/blob/master/src/proto/mod.proto
>> From what I understand, riemann server understands this proto implementation. You just can't send anything over gRPC.
>>
>> The idea I had in mind was to use this client and implement whatever is missing. Once the client is complete (it is already capable of sending events) we can use this as library crate for all monitoring agents we want to write. The monitoring agents will only collect information and this client library can be used to send event streams to Riemann.
>>

a trade-off is required from an engineering perspective.


the components on the agent side are
-------------
. daemon
. communicator
. executor
. sensor / probe
. logger
. cli


Brief
--------------
01. Daemon is a generic design and stand alone. It doesn't know anything about the platform or the communication protocol

02. Communicator knows only about communicating on a gRPC stream and HTTP/2

03. Executor is a command design pattern

04. sensor or probe is a poller/checker

05. logger writes a record given a stream or handle

06. cli is the interface to interact with the agent.

Here is an approach that i'd like to suggest and we can discuss this morning.


Key insight
------------
Both Ruby FFI and Rust FFI are very well designed, stable and work well with each other

Riemann client written in Ruby and the various Gems are already using a complete and stable gRPC implementation to communicate with the Riemman server.

Daemon, Executor, Sensor, Probe, Logger, CLI can be implemented very efficiently in Rust.


Approach
------------
A generic agent framework is designed using traits.
We use Ruby gRPC implementation 'as is' through FFI integration
Implement the rest of the components using Rust.

Rust gRPC implementation, trouble shooting, enhancement etc can be done over the next six months or so.

However, we got the core of the agents in Rust in this hackathon itself.

What say ?


warm regards
Saifi.

Sanchayan Maity

unread,
Dec 10, 2017, 10:13:38 AM12/10/17
to Rust Bangalore Community

As per our earlier discussion, let us know if you come across something in using Ruby inside Rust. I couldn't find anything.

Regards,
Sanchayan.

Reply all
Reply to author
Forward
0 new messages