This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

How to get the Alert triggered duration

Has anyone able to achive this

I am trying to get the duration in mins in advance alerts for which the alert has been generated

Something like

Alert RESET time - Alert Trigger time.

I can figure out something link ${DateTime - AlertTriggerTime}

now how to get this working.

Parents Reply Children
  • Hi,

    Is there some advance with this kind of Alert Trigger variable that shows the reset time or something like that, that shows the total amount of time for an outage on a reset alert?

    Thanks 

  • I would also like to know if this was implemented since 2009.  Currently I have Alert Trigger Time: ${AlertTriggerTime} & ${ShortTime} to show when the alert was triggered & reset.  However, If I have a delay on the Reset Timer I believe that the actual time the alarm was reset would be displayed incorrectly by ${ShortTime}. What would be displayed is the time the reset action is executed.

    For example, if a node goes down @ 1:00pm a trigger action (e.g. an e-mail) would be sent with alert time 1:00pm.

    Let's say it comes back up @ 1:10 pm but I have a 5 min delay on the Reset timer, I won't get an e-mail @ 1:10 i will get it @ 1:15 after the reset timer expires. Therefore the e-mail would be sent out with the time the e-mail was sent & not the time the reset condition was met.

    It would be good if there was a ${AertReset} variable. 

  • If you are just looking for the math to be done, you could try ${SQL:Select ${AlertTriggerTime} - ${ShortTime}}

     

    Edit: hmmm thats not working... I think the variable types are wrong... need to do a cast or something... let me look at this, unless anybody else can quickly fix my mistake here.

     

    Ok, does this work: ${SQL:Select Convert(time,Convert(datetime,'${Time}') - Convert(datetime,'${AlertTriggerTime}'))}

  • last one works :P

    just wanted to post that you need to convert it to the same type first :)

    thanks for this, integrated this into our alerts as a gimmick to see how long it took to solve the problem ;)

  • Hi netlogix,

     

    for some reason the query now produces sql errors:

    MACRO SQL ERROR - The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

     

    any idea on how to fix this?

  • hmmm...  I don't know.  The only thing I can think of right now is that is might have to do with some sort of roll-over happening (was it more than 24 hours?).  I'll start giving this some thought, in the mean time, can you see if there was anything out of the norm with that specific occurrence?  Or, is it happening all the time now?

    (The reason I am thinking roll over is because I didn't test that and I am not sure how I can... yet)

  • it did go to the next day, yes...

    All alerts I checked today seemed to have this behaviour, I'll check tomorrow and see if alerts resetting on the same day work fine

    PS: i am on APM 4.0.2 and NPM v10.1.2

  • it does not seem to be a rollover problem...

    we got this error for an alert that lasted 12minutes but not for an alert that rolled over...

    however an alert that lasted for more than 6weeks shows only the hours (6h42mins)

     

    whether it works or doesn't seems to be totally random for me

  • hmm... ok, thats what it will do for a day roll over, thats something else to figure out how to fix.

    It is still working fine for me, it could be odd or unexpected format of the string in Time or Alert Trigger Time, or the result of the math
    For now, can you add this to an alert that is having the issue?
    Time: '${Time}'
    Converted: '${SQL:Select Convert(datetime,'${Time}')}'

    AlertTriggerTime: '${AlertTriggerTime}'
    Converted: '${SQL:Select Convert(datetime,'${AlertTriggerTime}')}'

    With Math: '${SQL:Select Convert(datetime,'${Time}') - Convert(datetime,'${AlertTriggerTime}')}'

    The only other thing I could think of is to create a stored procedure to do this, but I don't like putting stored procedures in a database ... (I don't know how to say it, designed/owned/supported/updated/managed/serviced by someone else - solarwinds)

  • Ok, here is what I have now: ${SQL:Select datediff(day, Convert(datetime,'${AlertTriggerTime}'),Convert(datetime,'${Time}'))} days and ${SQL:Select Convert(time,Convert(datetime,'${Time}') - Convert(datetime,'${AlertTriggerTime}'))}

    It's a bit ugly, but I can't think of a better way without some type of extensive "if then else" logic that I don't know how to get it working.  I was hoping I could just apply a better format to it by changing the "Convert(time" to something like "Convert(duration", but I can't find anything easy like that.

    Questionario - Have you seen you more of the issue? any pattern?