2 Replies Latest reply on Jul 28, 2017 10:45 AM by AbhishekSK

    Unauthorized access using Ruby wavefront client

    AbhishekSK Enthusiast
    VMware Employees

      Tried using Ruby wavefront client (GitHub - wavefrontHQ/ruby-client: Ruby client for working with Wavefront ) to make the requests to wavefront. Following is the piece of code we are using. Have modified the token and the query here in the example. The request in the ruby code fails with 401 error : unauthorized access. But the same works fine with the curl get request.

       

      Ruby code :

       

      TOKEN ='3654000b-b9a4-46b8-94a0-0258b826fa25'

      wave = Wavefront::Client.new(TOKEN)

      response = wave.query('sum(rate(ts(~collector.points.valid)))', 'm', {tart_time => Time.now - 86400, :end_time => Time.now})

       

      Curl :

       

      curl -G "https://intuit.wavefront.com/chart/api?&s=1470153631&e=1470240031&g=s&i=false&strict=true" -H 'X-AUTH-TOKEN: 3654000b-b9a4-46b8-94a0-0258b826fa25' --data-urlencode 'q=sum(rate(ts(~collector.points.valid)))'

        • 1. Re: Unauthorized access using Ruby wavefront client
          AbhishekSK Enthusiast
          VMware Employees

          Had missed on specifying the host. Works fine!

          • 2. Re: Unauthorized access using Ruby wavefront client
            AbhishekSK Enthusiast
            VMware Employees

            Hi Samata,

            The Wavefront Client initializer takes up to 3 parameters:

            • token - A valid Wavefront API Token. This is required.
            • host - A String representing the Wavefront endpoint to connect to. Default: metrics.wavefront.com.
            • debug true|false - When set to true output RestClient debugging to stdout. Default: false.

             

            Looks like you are passing Token and so the default host is set to metrics.wavefront.com (which is our multi - tenant instance) . As Intuit has its own dedicated VPN instance you would need to pass host=intuit.wavefront.com

             

            Can you try updating your code to below

             

             

            TOKEN ='3654000b-b9a4-46b8-94a0-0258b826fa25'

            HOST = 'intuit.wavefront.com'

            wave = Wavefront::Client.new(TOKEN,HOST)

             

             

             

            Please let me know if this fixes things.

             

            Thanks,

            Salil D