Thursday, February 1, 2018

Getting Data Out of the StatsStore

After the release of the Oracle Solaris 11.4 Beta and the post on the new observability features by James McPherson I've had a few folks ask me if it's possible to export the data from the StatsStore into a format like CSV (Comma-separated values) so they can easily import this into something like Excel.

The answer is: Yes

The main command to access the StatsStore through the CLI is sstore(1), which you can either use as a single command or you can use it as an interactive shell-like environment. For example to browse the statistics namespace. The other way to access the StatsStore is through the Oracle Solaris Dashboard through a browser, where you point to the system's IP address on port 6787. A third way to access the data is through the REST interface (which the Dashboard actually also using to get it's data) but this is something for a later post.

As James pointed out in his post you can use sstore(1) to list the currently available resources, and you can use export to pull data from one or more of those resources. And it's with this last option you can specify the format you want this data to be exported as. The default is tab separated:

demo@solaris-vbox:~$ sstore export -t 2018-02-01T06:47:00 -e 2018-02-01T06:52:00 -i 60 '//:class.cpu//:stat.usage'
TIME                VALUE IDENTIFIER
2018-02-01T06:47:00 20286401.157722 //:class.cpu//:stat.usage
2018-02-01T06:48:00 20345863.706499 //:class.cpu//:stat.usage
2018-02-01T06:49:00 20405363.144286 //:class.cpu//:stat.usage
2018-02-01T06:50:00 20465694.085729 //:class.cpu//:stat.usage
2018-02-01T06:51:00 20525877.600447 //:class.cpu//:stat.usage
2018-02-01T06:52:00 20585941.862812 //:class.cpu//:stat.usage

But you can also get it in CSV:

demo@solaris-vbox:~$ sstore export -F csv -t 2018-02-01T06:47:00 -e 2018-02-01T06:52:00 -i 60 '//:class.cpu//:stat.usage'
time,//:class.cpu//:stat.usage
1517496420000000,20286401.157722
1517496480000000,20345863.706499
1517496540000000,20405363.144286
1517496600000000,20465694.085729
1517496660000000,20525877.600447
1517496720000000,20585941.862812

And in JSON:

demo@solaris-vbox:~$ sstore export -F json -t 2018-02-01T06:47:00 -e 2018-02-01T06:52:00 -i 60 '//:class.cpu//:stat.usage'
{
     "__version": 1,
     "data": [
          {
               "ssid": "//:class.cpu//:stat.usage",
               "records": [
                    {
                         "start-time": 1517496420000000,
                         "value": 20286401.157722
                    },
                    {
                         "start-time": 1517496480000000,
                         "value": 20345863.706498999
                    },
                    {
                         "start-time": 1517496540000000,
                         "value": 20405363.144285999
                    },
                    {
                         "start-time": 1517496600000000,
                         "value": 20465694.085728999
                    },
                    {
                         "start-time": 1517496660000000,
                         "value": 20525877.600446999
                    },
                    {
                         "start-time": 1517496720000000,
                         "value": 20585941.862812001
                    }
               ]
          }
     ]
}

Each of these have their own manual entries sstore.cvs(5) and sstore.json(5).

Now the question rises: How do you get something interesting/useful? Well, part of this is about learning what the StatsStore can gather for you and the types of tricks you can do with the data before you export it. This is where the Dashboard is a great learning guide. When you first log in you get a landing page very similar to this:

Note: The default install of Oracle Solaris won't have a valid cert and the browser will complain it's an untrusted connection. Because you know the system you can add an exception and connect.

Because this post is not about exploring the Dashboard but about exporting data I'll just focus on that. But by all means click around.

So if you click on the "CPU Utilization by mode (%)" graph you're essentially double clicking on that data and you'll got to a statistics sheet we've built showing all kinds of aspects on CPU utilization and this should look something like this:

Note: You can see my VirtualBox instance is pretty busy.

So these graphs look pretty interesting, but how do I get to this data? Well, if we're interested in the Top Processes, first click on Top Processes by CPU Utilization and this should bring up this overlay window:

Note: This shows this statistic is only temporarily collected (something you could make persistent here) and that the performance impact of collecting this statistic is very low.

Now click on "proc cpu-percentage" and this will show what is being collected to create this graph:

This shows the SSID of the data in this graph. A quick look at this show it's looking in the process data //:class.proc, then it's using a wildcard on the resources //:res.* which grabs all the entries available, then it selects the statistic for CPU usage in percent //:stat.cpu-percentage, and finally it does a top operation on this list and selects the to 5 processes //:op.top(5) (see ssid-op(7) for more info). And when I use this on the command line I get:

demo@solaris-vbox:~$ sstore export -F CSV -t 2018-02-01T06:47:00 -i 60 '//:class.proc//:res.*//:stat.cpu-percentage//:op.top(5)'
time,//:class.proc//:res.firefox/2035/demo//:stat.cpu-percentage//:op.top(5),//:class.proc//:res.rad/204/root//:stat.cpu-percentage//:op.top(5),//:class.proc//:res.gnome-shell/1316/demo//:stat.cpu-percentage//:op.top(5),//:class.proc//:res.Xorg/1039/root//:stat.cpu-percentage//:op.top(5),//:class.proc//:res.firefox/2030/demo//:stat.cpu-percentage//:op.top(5)
1517496480000000,31.378174,14.608765,1.272583,0.500488,0.778198
1517496540000000,33.743286,8.999634,3.271484,1.477051,2.059937
1517496600000000,41.018677,9.545898,5.603027,3.170776,3.070068
1517496660000000,37.011719,8.312988,1.940918,0.958252,1.275635
1517496720000000,29.541016,8.514404,9.561157,4.693604,0.869751

Where "-F CSV" tells it to output to CSV (I could also have used lowercase csv), "-t 2018-02-01T06:47:00" is the begin time of what I want to look at, I'm not using an end time which would be similar but then with an "-e", the "-i 60" tells it I want the length of each sample to be 60 seconds, and then I use the SSID from above.

Note: For the CSV export to work you'll need to specify at least the begin time (-t) and the length of each sample (-i), otherwise the export will error. You also want to export data the StatStore has actually gathered or it will also not work.

In the response the first line is the header with what each column is (time, firefox, rad, gnome-shell, Xorg, firefox) and then the values where the first column is UNIX time.

Similarly if I look at what data is driving the CPU Utilization graph I get the following data with this SSID:

demo@solaris-vbox:~$ sstore export -F csv -t 2018-02-01T06:47:00 -i 60 '//:class.cpu//:stat.usage//:part.mode(user,kernel,stolen,intr)//:op.rate//:op.util'
time,//:class.cpu//:stat.usage//:part.mode(user,kernel,stolen,intr)//:op.rate//:op.util(intr),//:class.cpu//:stat.usage//:part.mode(user,kernel,stolen,intr)//:op.rate//:op.util(kernel),//:class.cpu//:stat.usage//:part.mode(user,kernel,stolen,intr)//:op.rate//:op.util(user)
1517496420000000,2.184663,28.283780,31.322588
1517496480000000,2.254090,16.524862,32.667445
1517496540000000,1.568696,19.479255,41.112911
1517496600000000,1.906700,18.194955,39.069998
1517496660000000,2.326821,18.103397,39.564789
1517496720000000,2.484758,17.909993,38.684371

Note: Even though we've asked for data on user, kernel, stolen, and intr (interrupts), it doesn't return data on stolen as it doesn't have this.

Also Note: It's using two other operations rate and util in combination to create this result (also see ssid-op(7) for more info).

This should allow you to click around the Dashboard and learn what you can gather and how to export it. We'll talk more on mining interesting data and for example using the JSON output in later posts.

Join the discussion

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
 

Visit the Oracle Blog

 

Contact Us

Oracle

Integrated Cloud Applications & Platform Services