Documentation forSolarWinds Observability SaaS

Migrate custom metrics from AppOptics to SolarWinds Observability SaaS

SolarWinds Observability SaaS supports multiple methods for custom metrics collection, as described in Custom metrics.

SolarWinds Observability SaaS has a multidimensional metrics processing and visualization engine, which means that you can use the same metric name to report measurements related to multiple contexts. Reporting a value for the same metric in multiple contexts is standard practice in monitoring solutions.

When custom metrics are produced by end-user code, avoid generating metrics that are reported only in a single global context. For more information, see these guidelines.

Integrations with third-party metric collection tools

If you are populating AppOptics with custom metrics collected from Prometheus, StatsD, or Fluentd, see the following instructions to configure the integration in SolarWinds Observability SaaS:

APM SDK

If you are using the APM SDK for PHP or Node.js to report custom metrics, your metrics will be redirected automatically to SolarWinds Observability SaaS after you migrate the library to SolarWinds Observability SaaS.

The same is true for APM SKDs for other languages, but custom metrics support is available only in the latest versions (originated in SolarWinds Observability SaaS). Follow the appropriate link under How to upgrade to SolarWinds Observability SaaS libraries for migration instructions.

AppOptics REST endpoint

If you are using an AppOptics REST endpoint to report custom metrics to AppOptics, you can redirect those metrics to SolarWinds Observability SaaS. To do this, complete the following steps:

  1. Contact SolarWinds Support and request access to send data to the SolarWinds Observability SaaS endpoint.

    If you attempt to send data to this endpoint without access from Support, a Custom metrics disabled exception is returned.

  2. Change two things in your current implementation. See the examples in the following sections.

    • Instead of https://api.appoptics.com/v1/measurements, use the following endpoint address:

      https://custom-metrics.collector.xx-yy.cloud.solarwinds.com/v1/measurements

      The xx-yy variable represents the data center name. For more information, see Find the data center and endpoints for your organization.

    • Use a SolarWinds Observability SaaS token instead of the AppOptics token.

Python example

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import psutil
import requests
import time
#api_token = 'TOKEN_HERE'
api_token = 'SWO_TOKEN_HERE'
while True:
  cpu = psutil.cpu_percent(interval=None, percpu=False)
  memory = psutil.virtual_memory()
  payload = {'tags': {'language': 'python', 'device': 'maybe-a-macbook'},
             'measurements': [{'name': 'test.cpu', 'value': cpu},
                              {'name': 'test.mem', 'value': memory[2]}]}
#  print requests.post('https://api.appoptics.com/v1/measurements', auth=(api_token, ''), json=payload)
   print requests.post('https://collector.xx-yy.cloud.solarwinds.com/appoptics/v1/measurements', auth=(api_token, ''), json=payload)
  time.sleep(30)
Ruby Bash PHP PowerShell

Bash example

#APPOPTICS_TOKEN="TOKEN_HERE"
SWO_TOKEN="TOKEN_HERE"
#APPOPTICS_CREDENTIALS="${APPOPTICS_TOKEN}:"
SWO_CREDENTIALS="${APPOPTICS_TOKEN}:"
#APPOPTICS_API="https://api.appoptics.com"
SWO_API="https://collector.xx-yy.cloud.solarwinds.com"
while true; do
  cpu=$(ps aux | awk '{s=s+$3}; END{print s}')
  mem=$(ps aux | awk '{s=s+$4}; END{print s}')
  echo "%CPU: ${cpu}  %MEM: ${mem}"
 curl \
    -u $SWO_CREDENTIALS \
    -H "Content-Type: application/json" \
    -d '{
      "tags": {
        "device": "macbook",
        "language": "bash"
      },
      "measurements": [{
        "name": "cpu",
        "value": '$cpu'},
        {"name": "memory",
        "value": '$mem'}]
    }' \
    -X POST ${SWO_API}/v1/measurements
  sleep 30
done

PHP example

#!/usr/bin/php
<?php
//$url        = 'https://api.appoptics.com/v1/measurements';
$url          = 'https://collector.xx-yy.cloud.solarwinds.com/appoptics/v1/measurements'
//$api_token  = 'TOKEN_HERE';
$api_token    = 'SWO_TOKEN_HERE';
$curl = curl_init($url);
$curl_post_data = array(
  "measurements" => array(
   array("name" => "php-example-0", "value" => "22", "tags" => array("test" => "test-1"))
   )
);
$headers = array(
    'Content-Type: application/json'
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($curl_post_data));
curl_setopt($curl, CURLOPT_USERPWD, "$api_token:");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
echo "HTTP Status Code: " . $http_status;
echo $result
?>

PowerShell example

#requires -version 2.0

#Enable TLS 1.2 for PowerShell
[Net.ServicePointManager]::SecurityProtocol =
[Net.SecurityProtocolType]::Tls12

#AppOptics API Token
#$TOKEN = "AO_TOKEN_HERE"

#SWO API Token
$TOKEN = "SWO_TOKEN_HERE"

#Prevent Credential Window prompt by creating a user
$API_TOKEN = New-Object System.Management.Automation.PSCredential ($TOKEN,(new-object System.Security.SecureString))

#Get CPU Percent Used
$CPU = Get-WmiObject -Query "SELECT PercentProcessorTime FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'"

#Get Memory Availailble in MegaBytes
$MEM= Get-WmiObject -Query "SELECT AvailableMBytes FROM Win32_PerfFormattedData_PerfOS_Memory"

#Create Hashtable for metrics
$HTABLE = @{
    "tags" = @{
        "device" = "winvm"
        "language" = "ps"
    }
    "measurements" = @(
        [ordered]@{
        "name" = "cpu"
        "value" = $CPU.PercentProcessorTime
        },
        [ordered]@{
        "name" = "memory"
        "value" = $MEM.AvailableMBytes
        }
    )
}

#Convert Hasttable to JSON omitting whitespace
$BODY = (ConvertTo-Json -InputObject $HTABLE -Depth 4 -Compress)

#Publish metric to API
#$CMD = Invoke-RestMethod -Uri "https://api.appoptics.com/v1/measurements" -Method Post -ContentType "application/json" -Credential $API_TOKEN -Body $BODY
$CMD = Invoke-RestMethod -Uri "https://collector.xx-yy.cloud.solarwinds.com/appoptics/v1/measurements" -Method Post -ContentType "application/json" -Credential $API_TOKEN -Body $BODY

Kubernetes

If your application is running in a Kubernetes cluster, you can collect all custom metrics exposed within the cluster using Prometheus style endpoints by configuring Kubernetes monitoring. For more information about this functionality, see K8s integration. For more information about setting up Prometheus monitoring, see Kubernetes monitoring.