Return value from embedded object

20 views
Skip to first unread message

Brad Dixon

unread,
Sep 17, 2012, 8:36:51 AM9/17/12
to cube...@googlegroups.com
As a learning exercise I am using a dtrace script to extract data from my system and then filing it away to cube. Right now the JSON I store looks like this:

{
  "load1": 0.99,
  "load5": 1.47,
  "load15": 1.73,
  "syscalls": 2035,
  "log": {
    "fstat64": 14,
    "open": 14,
    "gettimeofday": 15,
  }
}

The dtrace script records one event like this per second. I'm trying to write a metric that returns the number of open calls. Right now I've got:

cube-get metric 'sum(topsyscall.gt(log.open,0))' --start yesterday@23:38 --step 10s

Which returns:

09/17/2012 08:31:10;1
09/17/2012 08:31:20;3
09/17/2012 08:31:30;5

This is the number of events which had an open syscall. I'd like to instead return the sum of the log.syscall entries but I can't seem to figure out how to access the inner embedded object:

cube-get event 'topsyscall(log.open).gt(log.open,0)' --start yesterday@23:38 

returns:

09/17/2012 08:32:34;[object Object]

Perhaps this just can't be done with cube-get and I need to either write my own query client or flatten my data but I thought I'd ask if anyone had suggestions.

Thanks,

Brad

Mike Bostock

unread,
Sep 17, 2012, 12:23:59 PM9/17/12
to cube...@googlegroups.com
Is this what you meant?

sum(topsyscall(syscalls).gt(log.open, 0))

You said you want to "return the sum of the log.syscall entries", but
there is no `log.syscall` property in your data—only a `syscalls`
property.

Mike

Brad Dixon

unread,
Sep 18, 2012, 1:57:33 PM9/18/12
to cube...@googlegroups.com
On Monday, September 17, 2012 12:24:20 PM UTC-4, Mike Bostock wrote:
Is this what you meant?

  sum(topsyscall(syscalls).gt(log.open, 0))

Mike... thanks. I see now that I can return the metric summing all of the open sys calls:

sum(topsyscall(log.open).gt(log.open,0))

Which could of course be simplified to sum(topsyscall(log.open))

Trying to return the events individually (using cube-get) leaves me with a sequence of [object Object] responses:

09/18/2012 13:54:09;[object Object]

but if I look at the json value returned from the request I can see that it is just fine:

$ curl `cube-get event 'topsyscall(log.open)' --start today@13:50  -r` | json | tail

  },
  {
    "time": "2012-09-18T17:56:27.517Z",
    "data": {
      "log": {
        "open": 370
      }
    }
  }
]

I appreciate your help!

Thanks,

B
Reply all
Reply to author
Forward
0 new messages