locked
Can I create a Custom Performance Counter after startup? RRS feed

  • Question

  • I am using Custom Performance Counters in my Azure WebRole. The counters are created in a startup task with elevated permission. However my WebRole needs to create more counters dynamically after the startup. It looks like I can not use the startup task because at this point startup taks is finished. What are my options to create a Custom Performance Counter after the the WebRole has started?


    • Edited by Alex Koval Sunday, May 29, 2011 3:25 PM typo
    Sunday, May 29, 2011 2:34 AM

Answers

  • Hi Igor,

    Do you mean to run the startup task as a background process indefinetely and expose an endpoint? If so would you suggest a WCF service with some endpoint configured at localhost IP? Or should that be a raw socket connection?

    Has anybody experimented with azure startup task in this way?

    Thank you for your valuable advice.

    regards,

     

    Alex

    I actually sorta like the WCF idea as well, but I was suggesting something even simpler:

    The command from the startup task must exit in order for the role to start, so use it to shell a small TSR (terminate and stay resident) program instead.  This TSR would have an infinite loop that would check every few seconds local folder for a presence of some file (XML?)... once the file would be present, the TSR would read the file's contents which would be instructions on which counters need creating and then TSR would create those counters.

    This approach should work for simple non-too-frequent requests to create counters.  And since in theory, you shouldn't need to be creating new counters or categories often, this maybe OK... also, you're not losing any endpoints of which there is a finite limit and keeping the thing super simple as this can be done with a few lines of code and without having to deal with a lot of configuration options... but definitely seems more crude than an elegant local WCF service :)


    Auto-scaling & monitoring service for Windows Azure applications at http://www.paraleap.com
    • Marked as answer by Wenchao Zeng Monday, June 6, 2011 1:45 AM
    Tuesday, May 31, 2011 5:19 AM

All replies

  • I think you have to use onstart method to create all of your performance counters. Not startup task. If you need to create more of performance counters create some performance counters onchange event :-) maybe...my opinion


    Windows Azure Consultant http://cloudikka.wordpress.com/ (Don't open this link, if you don't understand czech language)
    Monday, May 30, 2011 12:47 AM
  • One needs to use a startup task with elevated privileges in order to create custom perf counters.

     

    I wonder if it's possible for the startup task to shell out a small resident listener that would run with elevated privileges and listen for a command from the Webrole (could be as simple as a presence of some local file with instructions on which counters to create)


    Auto-scaling & monitoring service for Windows Azure applications at http://www.paraleap.com
    • Proposed as answer by Mike Erickson Monday, May 30, 2011 6:32 AM
    Monday, May 30, 2011 12:56 AM
  • Hi Igor,

    Do you mean to run the startup task as a background process indefinetely and expose an endpoint? If so would you suggest a WCF service with some endpoint configured at localhost IP? Or should that be a raw socket connection?

    Has anybody experimented with azure startup task in this way?

    Thank you for your valuable advice.

    regards,

     

    Alex

    Tuesday, May 31, 2011 5:11 AM
  • Hi Igor,

    Do you mean to run the startup task as a background process indefinetely and expose an endpoint? If so would you suggest a WCF service with some endpoint configured at localhost IP? Or should that be a raw socket connection?

    Has anybody experimented with azure startup task in this way?

    Thank you for your valuable advice.

    regards,

     

    Alex

    I actually sorta like the WCF idea as well, but I was suggesting something even simpler:

    The command from the startup task must exit in order for the role to start, so use it to shell a small TSR (terminate and stay resident) program instead.  This TSR would have an infinite loop that would check every few seconds local folder for a presence of some file (XML?)... once the file would be present, the TSR would read the file's contents which would be instructions on which counters need creating and then TSR would create those counters.

    This approach should work for simple non-too-frequent requests to create counters.  And since in theory, you shouldn't need to be creating new counters or categories often, this maybe OK... also, you're not losing any endpoints of which there is a finite limit and keeping the thing super simple as this can be done with a few lines of code and without having to deal with a lot of configuration options... but definitely seems more crude than an elegant local WCF service :)


    Auto-scaling & monitoring service for Windows Azure applications at http://www.paraleap.com
    • Marked as answer by Wenchao Zeng Monday, June 6, 2011 1:45 AM
    Tuesday, May 31, 2011 5:19 AM