Ready to get started?


Learn More

Access Splunk Data in PHP through the Cloud Hub

Connect to Splunk through the standard MySQL libraries in PHP.

You can use the CData Cloud Hub to access Splunk data from MySQL clients, without needing to perform an ETL or cache data. Follow the steps below to create a virtual MySQL database for Splunk and connect to Splunk data in real time through PHP's standard MySQL interfaces, mysqli and PDO_MySQL.

The CData Cloud Hub provides a pure MySQL, cloud-to-cloud interface for Splunk, allowing you to easily query live Splunk data in PHP — without replicating the data to a natively supported database. As you query data in PHP, the CData Cloud Hub pushes all supported SQL operations (filters, JOINs, etc) directly to Splunk, leveraging server-side processing to quickly return Splunk data.

Create a Virtual MySQL Database for Splunk Data


  1. Connect to the CData Cloud Hub:
    mysql --host myinstance.cdatacloud.net --user admin --password
  2. Once authenticated, create the virtual database for Splunk:
    mysql> CREATE DATABASE splunkdb
        -> DRIVER = "Splunk",


Connect in PHP


  • Password: Specify the password for the authorized user account.
  • Database Name: Specify the name of the virtual database you created for Splunk.


$mysqli = mysqli_init();


$mysqli->real_connect("mysintance.cdatacloud.net", "admin", "mypassword", "splunkdb",3306,NULL,MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);


$pdo = new PDO('mysql:host=myinstance.cdatacloud.net;dbname=splunkdb;port=3306;','admin', 'mypassword', array(

Query in PHP


  1. Query the table; for example, DataModels. The results will be stored as an associative array in the $result object.
  3. Close the connection.


$result = $mysqli->query("SELECT Name, Owner FROM DataModels");
    echo "$k : $v";
    echo "<br />"; 


$result = $pdo->query("SELECT Name, Owner FROM DataModels");
    echo "$k : $v";
    echo "<br />"; 
$result = null;
$pdo = null;