Refine your search:

I have a search that I'm using to populate some charts in a dashboard. The search is checking a log and charting the top 20 users who have used the most disk space in their home directories. It works great for a 24 hour period...However I can't seem to get it to work for longer periods such as 7 days or more.

What I'd like to do is that if you choose 7 days, it would display the top 20 users who were using the most space after pretty much calculating space usage for 7 days per user. You'd be able to see the user's space usage over a 7 day period. This would allow you to see when a spike may have occurred that caused a disk issue.

The search I have right now is :

host="ynfs1" sourcetype=userdiskusage earliest=-1d@d latest=-0d@d | rex field=_raw "(?<Space>[\d]+)\s*\/home\/(?<UserName>\S+)" max_match=1000 | search NOT UserName="shares" | table UserName Space | sort -Space | head 20

This search is used to create an area chart on a dashboard. I have a time range picker to change the time from 24 hours to 7 days, but when I do the results are not what I would like. Nothing happens for the most part. Here's my dashboard code:

    <view template="dashboard.html">
  <label>YNFS1 Space Usage</label>
  <module name="AccountBar" layoutPanel="navigationHeader"/>
  <module name="AppBar" layoutPanel="navigationHeader"/>

  <module name="Message" layoutPanel="messaging">
    <param name="filter">*</param>
    <param name="clearOnJobDispatch">False</param>
    <param name="maxSize">1</param>
  </module>

  <module name="TimeRangePicker" layoutPanel="panel_row1_col1">
    <param name="searchWhenChanged">True</param>
    <param name="default">Last 24 hours</param>
      <module name="HiddenSavedSearch" layoutPanel="panel_row2_col1" group="Space Usage by user over a given time" autoRun="True">
        <param name="savedSearch">Andrew ynfs1 search</param>
        <module name="HiddenChartFormatter">
          <param name="charting.chart">area</param>
          <param name="chart.stackMode">stacked</param>
          <param name="secondaryAxisTitle.text">Space</param>
          <module name="JobProgressIndicator"></module>
            <module name="FlashChart">
              <param name="width">100%</param>
              <param name="height">400px</param>
            </module>
          </module>
          <module name="ViewRedirectorLink">
            <param name="viewTarget">flashtimeline</param>
            <param name="popup">True</param>      
          </module> 
      </module>
      <module name="HiddenSavedSearch" layoutPanel="panel_row3_col1" group="Space Usage by user over a given time" autoRun="True">
        <param name="savedSearch">Andrew ynfs1 search</param>
        <module name="HiddenChartFormatter">
          <param name="charting.chart">pie</param>
          <module name="JobProgressIndicator">
            <module name="FlashChart">
              <param name="width">100%</param>
              <param name="height">400px</param>
             </module>
          </module>
          <module name="ViewRedirectorLink">
            <param name="viewTarget">flashtimeline</param>
            <param name="popup">True</param>      
          </module> 
        </module>
     </module>
     <module name="HiddenSavedSearch" layoutPanel="panel_row3_col2" group="Space Usage by user over a given time" autoRun="True">
       <param name="savedSearch">Andrew ynfs1 search</param>
       <module name="SimpleResultsTable"></module>
       <module name="ViewRedirectorLink">
         <param name="viewTarget">flashtimeline</param>
         <param name="popup">True</param>      
       </module> 
    </module>
  </module> 
</view>

I've been looking into timechart as I believe I have to use this command to make this happen. I also tried doing a timechart sum of Space by Username but the results didn't look right. Any ideas?

asked 07 Dec '11, 11:51

gnovak's gravatar image

gnovak
5362423
accept rate: 20%

edited 07 Dec '11, 12:12


2 Answers:

I think the first issue here is that you hardcoded the timerange into the search. try removing the earliest and latest. That should fix your timerange dropdown issue. Try the following search

host="ynfs1" sourcetype=userdiskusage | rex field=_raw "(?<space>[d]+)s*/home/(?<username>S+)" max_match=1000 | search NOT UserName="shares" | bucket _time span=1d | eval day=strftime(day,"%Y-%m-%d") | chart sum(Space) over day by UserName

link

answered 07 Dec '11, 12:31

Joetron's gravatar image

Joetron
1.9k1212
accept rate: 25%

You should be able to chart this. If you want to have a little more granularity into space usage, change the span to 1h or 1m or whatever you want.

(07 Dec '11, 12:35) Joetron

it just says no results found and the charts are empty.

(07 Dec '11, 13:06) gnovak

let me try running it manually

(07 Dec '11, 13:06) gnovak

my bad run this:

host="ynfs1" sourcetype=userdiskusage | rex field=_raw "(?<space>[d]+)s*/home/(?<username>S+)" max_match=1000 | search NOT UserName="shares" | bucket _time span=1d as day | eval day=strftime(day,"%Y-%m-%d") | chart sum(Space) over day by UserName

I forgot to add the "as day" after bucket _time span=1d It should work now.

(07 Dec '11, 13:18) Joetron

still not working. what's the eval day=strftime

(07 Dec '11, 13:28) gnovak

ah it looks like your rex field extraction is all lowercase. try this:

host="ynfs1" sourcetype=userdiskusage | rex field=_raw "(?<space>[d]+)s*/home/(?<username>S+)" max_match=1000 | search NOT UserName="shares" | bucket _time span=1d as day | eval day=strftime(day,"%Y-%m-%d") | chart sum(space) over day by userame

strftime: This function takes an epochtime value, X, as the first argument and renders it as a string using the format specified by Y.

(07 Dec '11, 13:33) Joetron

The search stops producing any results as soon as I do the chart command. I tried using timechart but didn't seem to get it right. Also the only results I have is a list of _time and that's it.

(07 Dec '11, 13:34) gnovak

also i left the hardcoded time range in the search just to see if the charts did work. my bad

(07 Dec '11, 13:34) gnovak

it's not a case issue. that didn't work

(07 Dec '11, 13:38) gnovak

Also what about the | head 20? How is this search going to show me the top 20 disk hogs over a period of time?

(07 Dec '11, 13:41) gnovak

even this doesn't work. As soon as I put the | chart command nothing happens. host="ynfs1" sourcetype=userdiskusage | rex field=_raw "(?<space>[d]+)s*/home/(?<username>S+)" max_match=1000 | search NOT UserName="shares" | bucket _time span=1d as day | eval day=strftime(day,"%Y-%m-%d") | head 20 | chart sum(Space) by UserName

(07 Dec '11, 13:42) gnovak

I'm going to look at the Time Based Charting Tools in UI examples for some hints. ugh!

(07 Dec '11, 14:01) gnovak

what is a typical result for your space field look like?

(07 Dec '11, 14:08) Joetron

UserName Space 1 bruce 43236824 2 fhu 41706896 3 lfan 39659892 4 hzhou 32397800 5 gsp 29841020 6 lyuan 29492256 7 mkarimi 27565896 8 jfu 25898072 9 jpfletch 25440672 10 mselvi 25278628

(07 Dec '11, 14:12) gnovak

looks like this using the original search i posted.

(07 Dec '11, 14:12) gnovak
host="ynfs1" sourcetype=userdiskusage earliest=-1d@d latest=-0d@d | rex field=_raw "(?<Space>[\d]+)\s*\/home\/(?<UserName>\S+)" max_match=1000 | search NOT UserName="shares" | chart sum(Space) over UserName

Does that produce anything when typed in exactly?

link

answered 07 Dec '11, 14:18

Joetron's gravatar image

Joetron
1.9k1212
accept rate: 25%

yep i got stuff

(07 Dec '11, 14:22) gnovak

let me try something

(07 Dec '11, 14:22) gnovak

this produces results host="ynfs1" sourcetype=userdiskusage earliest=-1d@d latest=-0d@d | rex field=_raw "(?<space>[d]+)s*/home/(?<username>S+)" max_match=1000 | search NOT UserName="shares" | bucket _time span=1d as day | eval day=strftime(day,"%Y-%m-%d") | chart sum(Space) over UserName | sort -Space

(07 Dec '11, 14:27) gnovak

however this is not showing me the top 20 in the list. host="ynfs1" sourcetype=userdiskusage earliest=-1d@d latest=-0d@d | rex field=_raw "(?<space>[d]+)s*/home/(?<username>S+)" max_match=1000 | search NOT UserName="shares" | bucket _time span=1d as day | eval day=strftime(day,"%Y-%m-%d") | chart sum(Space) over UserName | sort -Space | head 20

(07 Dec '11, 14:28) gnovak

For my use case i don't use the sort command, my users prefer to sort the results themselves by clicking the sort buttons under the day columns.

(07 Dec '11, 14:34) Joetron

well they want the top 20 based on their space consumption. So i said to sort the list and then show me the first 20 in the list.

(07 Dec '11, 14:39) gnovak

I'm looking at the advanced_intro2 in the UI examples and it's got pretty much the same thing. :/

(07 Dec '11, 14:41) gnovak

at this point i'm thinking the graph should have the time at the bottom, the space on the left (which i might convert to mb eventually) and for the legend have the top 10 or 20 users using the most disk space over time identified by colors

(07 Dec '11, 15:08) gnovak
Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×290

Asked: 07 Dec '11, 11:51

Seen: 981 times

Last updated: 07 Dec '11, 15:47

Copyright © 2005-2012 Splunk Inc. All rights reserved.