Exemple #1
0
 def __init__(self, base_url=WAVEFRONT_BASE_URL,
              api_key=WAVEFRONT_API_TOKEN):
     self.wavefront_client = wavefront_api_client.ApiClient(
         host=WAVEFRONT_BASE_URL,
         header_name='Authorization',
         header_value='Bearer ' + WAVEFRONT_API_TOKEN
     )
Exemple #2
0
def retrieveClient(endpoint, token):
    config = wave_api.Configuration()
    config.host = endpoint
    client = wave_api.ApiClient(configuration=config,
                                header_name='Authorization',
                                header_value='Bearer ' + token)
    return client
Exemple #3
0
def get_wfclient(base_url, api_key):
    # Returns Wavefront client object
    config = wave_api.Configuration()
    config.host = base_url
    client = wave_api.ApiClient(configuration=config,
                                header_name='Authorization',
                                header_value='Bearer ' + api_key)
    return client
Exemple #4
0
def createWavefrontClient():
    config = wave_api.Configuration()    
    config.host = globalConfig.getValueByKey('WAVEFRONT_ENDPOINT')
    token = globalConfig.getValueByKey('WAVEFRONT_TOKEN')
    if (config.host=='' or token==''):
        logger.error("wavefront endpoint or token is null")
        return None
    try:
        global client 
        client = wave_api.ApiClient(configuration=config, header_name='Authorization', header_value='Bearer ' + token)
        return client
    except Exception as e:
        logger.error("wave_api.ApiClient call failed "+str(e))
    return None
 def __init__(self, query):
     '''
     query: str: WF query
     '''
     super(WavefrontScraper, self).__init__()
     config = wave_api.Configuration()
     config.host = base_url
     client = wave_api.ApiClient(configuration=config,
                                 header_name='Authorization',
                                 header_value='Bearer ' + api_key)
     self.query_api = wave_api.QueryApi(client)
     self.query = query
     # query by minute
     self.interval = 'm'
Exemple #6
0
    def getWavefrontApiClient(self):
        """Crete and return the wavefrontApiClient object"""

        if self.wavefrontApiClient:
            return self.wavefrontApiClient

        host = self.getWavefrontHost()
        apiToken = self.getApiToken()

        config = wavefront_api_client.Configuration()
        config.host = host

        self.wavefrontApiClient = wavefront_api_client.ApiClient(
            configuration=config,
            header_name="Authorization",
            header_value="Bearer " + apiToken)

        return self.wavefrontApiClient
import wavefront_api_client as wave_api
import sys

base_url = 'https://try.wavefront.com'
api_key = sys.argv[1]
config = wave_api.Configuration()
config.host = base_url
client = wave_api.ApiClient(configuration=config,
                            header_name='Authorization',
                            header_value='Bearer ' + api_key)

# instantiate source API
#source_api = wave_api.SourceApi(client)
#sources = source_api.get_all_source()
#print (sources)

id = 'robs-test-dashboard'
dashboard_api = wave_api.DashboardApi(client)
dashboard = dashboard_api.get_dashboard(id)
print(dashboard)
from __future__ import print_function
import wavefront_api_client
from wavefront_api_client.rest import ApiException
from benchmark.utils import response_tostats, RuntimeObjects
from enum import Enum, auto
import pandas as pd
import numpy as np
from urllib3.exceptions import MaxRetryError

prod_config = wavefront_api_client.Configuration()
prod_config.host = "https://varca.wavefront.com"
prod_config.api_key['X-AUTH-TOKEN'] = '10a79735-3ed2-4cbd-bb3b-5ddecf2a06f7'
# create an instance of the API class
prod_api_instance = wavefront_api_client.QueryApi(wavefront_api_client.ApiClient(prod_config))

try:
    symphony_config = wavefront_api_client.Configuration()
    symphony_config.host = "https://symphony.wavefront.com"
    symphony_config.api_key['X-AUTH-TOKEN'] = 'e2b2f93e-0ce4-4757-8f4d-2a67e41ac57a'

    symphony_api_instance = wavefront_api_client.QueryApi(wavefront_api_client.ApiClient(symphony_config))
except Exception as e:
    symphony_api_instance = None

# Metrices for whom we take only top K candidates. 20 in this case
lst = ["Program time", "Denorm Latency By Object Type", "Input SDM", "Object Churn"]


# Priority of metrics. High priority metric breaches will
# be highlighted first
class Priority(Enum):
Exemple #9
0
from pymongo import MongoClient
import pymongo
from bson import json_util

import wavefront_api_client

# ------ WAVEFRONT INTEGRATION -------

# Configure API key authorization: api_key
wavefrontConfiguration = wavefront_api_client.Configuration()
wavefrontConfiguration.host = 'https://vmware.wavefront.com'
wavefrontConfiguration.api_key[
    'X-AUTH-TOKEN'] = '7dd79888-59fb-42f0-84a7-2a83545de7f0'

wavefrontApiInstance = wavefront_api_client.DirectIngestionApi(
    wavefront_api_client.ApiClient(wavefrontConfiguration))
wavefrontDataFormat = 'wavefront'
wavefrontMetricSourceName_AstroApiResponse = 'kr.astro.external.api.response'

wavefrontMetricName_AstroApiResponse = 'kr.astro.api'
wavefrontMetricName_GoogleApiResponse = 'kr.google.api'


def wavefrontDirectSenderSingleMetric(wavefrontMetricName,
                                      wavefrontMetricSourceName, metricValue):
    body = wavefrontMetricName + ' ' + str(
        metricValue) + ' source=' + wavefrontMetricSourceName
    wavefrontApiInstance.report(f=wavefrontDataFormat, body=body)
    return body

Exemple #10
0
        '/controllers/([0-9]{1,3})/temp', 'Temp',
        '/controllers/([0-9]{1,3})/unregister', 'Unregister',
        '/controllers/([0-9]{1,3})/version', 'Version', '/version',
        'MyVersion')

app = web.application(urls, globals())

# ------ WAVEFRONT INTEGRATION -------

if _WFTOKEN_ != "Disabled":
    # Configure API key authorization: api_key
    wfConfig = wf_api.Configuration()
    wfConfig.host = 'https://vmware.wavefront.com'
    wfConfig.api_key['X-AUTH-TOKEN'] = _WFTOKEN_

    wfApiInstance = wf_api.DirectIngestionApi(wf_api.ApiClient(wfConfig))
    wfDataFormat = 'wavefront'
    wfMetricSourceName_GrApi = "gr.api." + _WF_SRC_

    def wfDirectSenderSingleMetric(wfMetricName, wfMetricSourceName,
                                   metricValue):
        body = wfMetricName + ' ' + str(
            metricValue) + ' source=' + wfMetricSourceName
        wfApiInstance.report(f=wfDataFormat, body=body)
        return body


# ------------------------------------


def client(data, host, port):
from __future__ import print_function
import wavefront_api_client
from wavefront_api_client.rest import ApiException
from benchmark.utils import response_tostats, RuntimeObjects
from enum import Enum, auto
import pandas as pd
import numpy as np
from urllib3.exceptions import MaxRetryError

prod_config = wavefront_api_client.Configuration()
prod_config.host = "https://varca.wavefront.com"
prod_config.api_key['X-AUTH-TOKEN'] = '10a79735-3ed2-4cbd-bb3b-5ddecf2a06f7'
# create an instance of the API class
prod_api_instance = wavefront_api_client.QueryApi(
    wavefront_api_client.ApiClient(prod_config))

try:
    symphony_config = wavefront_api_client.Configuration()
    symphony_config.host = "https://symphony.wavefront.com"
    symphony_config.api_key[
        'X-AUTH-TOKEN'] = 'e2b2f93e-0ce4-4757-8f4d-2a67e41ac57a'

    symphony_api_instance = wavefront_api_client.QueryApi(
        wavefront_api_client.ApiClient(symphony_config))
except Exception as e:
    symphony_api_instance = None

# Metrices for whom we take only top K candidates. 20 in this case
lst = [
    "Program time", "Denorm Latency By Object Type", "Input SDM",
    "Object Churn"
Exemple #12
0
import wavefront_api_client as wave_api

base_url = 'https://try.wavefront.com'
api_key = 'YOUR_API_KEY'

client = wave_api.ApiClient(host=base_url,
                            header_name='Authorization',
                            header_value='Bearer ' + api_key)

# instantiate source API

source_api = wave_api.SourceApi(client)

sources = source_api.get_all_source()

print sources
Exemple #13
0
def main():

    alert, dashboard = ["alert", "dashboard"]

    parser = argparse.ArgumentParser(
        description="""A tool to create test fixtures using the latest version of
        the wavefront server. In wavectl tests, we have local representations
        of the json data that is returned by the wavefront api server. Depending
        on the server version and the api version, this data may change over time.
        With this script one could update the locally saves json test fixtures."""
    )
    parser.add_argument("wavefrontHost",
                        help="""Speficy the url of the wavefront host.""")
    parser.add_argument("apiToken",
                        help="""Speficy the api token to use while
        communicating with the wavefront host.""")
    parser.add_argument(
        "rsrcType",
        choices=[alert, dashboard],
        help="Specify the resource kind represented in the file")
    parser.add_argument("inFile", help="Input File")
    parser.add_argument("outFile", help="Out File")

    args = parser.parse_args()

    config = wavefront_api_client.Configuration()
    config.host = args.wavefrontHost
    wavefrontClient = wavefront_api_client.ApiClient(
        configuration=config,
        header_name="Authorization",
        header_value="Bearer " + args.apiToken)

    alertApi = wavefront_api_client.AlertApi(wavefrontClient)
    dashboardApi = wavefront_api_client.DashboardApi(wavefrontClient)
    searchApi = wavefront_api_client.SearchApi(wavefrontClient)

    with open(args.inFile) as f:
        inRsrcs = json.load(f)

    uKey = "id"
    if args.rsrcType == alert:
        api = alertApi
        createFunc = api.create_alert
        searchFunc = searchApi.search_alert_entities
        delFunc = api.delete_alert
    elif args.rsrcType == dashboard:
        api = dashboardApi
        createFunc = api.create_dashboard
        searchFunc = searchApi.search_dashboard_entities
        delFunc = api.delete_dashboard
    else:
        assert not "Unexpected value in rsrcType parameter"

    outRsrcs = []
    for r in inRsrcs:
        createFuncParams = {"body": r}
        rawRes = createFunc(_preload_content=False, **createFuncParams)
        strRes = rawRes.read().decode('utf-8')
        res = json.loads(strRes)["response"]
        outRsrcs.append(res)

    with open(args.outFile, "w") as f:
        json.dump(outRsrcs,
                  f,
                  indent=4,
                  sort_keys=True,
                  separators=(',', ': '))

    # Permanently delete every rsrc
    for r in outRsrcs:
        uId = r[uKey]
        delFunc(uId, _preload_content=False)
        delFunc(uId, _preload_content=False)