icon/x Created with Sketch.

Splunk Cookie Policy

We use our own and third-party cookies to provide you with a great online experience. We also use these cookies to improve our products and services, support our marketing campaigns, and advertise to you on our website and other websites. Some cookies may continue to collect information after you have left our website. Learn more (including how to update your settings) here.
Accept Cookie Policy

We are working on something new...

A Fresh New Splunkbase
We are designing a New Splunkbase to improve search and discoverability of apps. Check out our new and improved features like Categories and Collections. New Splunkbase is currently in preview mode, as it is under active development. We welcome you to navigate New Splunkbase and give us feedback.

Accept License Agreements

This app is provided by a third party and your right to use the app is in accordance with the license provided by that third-party licensor. Splunk is not responsible for any third-party apps and does not provide any warranty or support. If you have any questions, complaints or claims with respect to this app, please contact the licensor directly.

Thank You

Downloading R Analytics
SHA256 checksum (r-analytics_101.tgz) d2a73302e79db2cb74197615dbeead1cc164f6222af84306ccdf3a457d4540f0
To install your download
For instructions specific to your download, click the Details tab after closing this window.

Flag As Inappropriate

splunk

R Analytics

This app has been archived. Learn more about app archiving.
This app is NOT supported by Splunk. Please read about what that means for you here.
Overview
Details
The R app for Splunk allows users to run R code on a remote R server, right from the Splunk interface. The app adds a script editor, which allows you to interact with Splunk and R from the same dashboard, as well as several example dashboards with visualizations build by R. Finally the app exposes the runRdo command, which allows users to run any R code from the Splunk search bar.

R Analytics app Splunk

Installation

Unzip this folder in your Splunk installation $SPLUNK_HOME/etc/apps and restart Splunk. On your R server install OpenCPU (https://www.opencpu.org/download.html). In Splunk go to the setup page of the R app and fill out the address of your OpenCPU installation.

Installing packages

OpenCPU will create a new session (and user) for every request it gets. These sessions will be removed after some time. Packages installed in such a session are not available to other sessions and will be removed once the session is removed. Installing packages globally can be done by installing them to the /usr/local/lib/R/site-library directory or by running the following from the command line:

sudo R
install.packages(<package_name>, lib = "/usr/local/lib/R/site-library")

The full documentation of OpenCPU can be found here: https://cran.r-project.org/web/packages/opencpu/vignettes/opencpu-server.pdf (Chapter 3.2 deals with installing packages)

Examples

Search in Splunk, send the data to R and retrieve the full dataset:

search index=_internal | head 10 | runRdo script="return(dataset);"

Using R libraries in Splunk and returning links to images (or the console) instead of results:

| inputlookup iris.csv 
| fields - species 
| runRdo script="library(corrplot); correlationMatrix = cor(dataset); corrplot(correlationMatrix);" getResults=f

Datatypes and column order (thanks to jedatt01 on Splunk Answers for the example: https://answers.splunk.com/answers/455710/potential-bug-in-r-analytics-app.html)

| inputlookup iris.csv 
| runRdo script="
    # Fix the random seed
    set.seed(1);

    # Store the dataset in a variable
    my_iris = dataset;

    # Seperate the species column from the rest
    species = as.factor(my_iris$species);
    my_iris = my_iris[ , !(names(my_iris) %in% c('species'))];

    # Cast data types
    my_iris$petal_length = as.numeric(my_iris$petal_length);
    my_iris$sepal_length = as.numeric(my_iris$sepal_length);
    my_iris$petal_width = as.numeric(my_iris$petal_width);
    my_iris$sepal_width = as.numeric(my_iris$sepal_width);

    # Show summaries in the console, use getResults=false to see the link to the console
    str(species);
    str(my_iris);

    # Perform the kmeans
    kmeans_iris = kmeans(my_iris, 3);
    kmeans_table = table(kmeans_iris$cluster, species);

    # Return a dataframe
    return(as.data.frame(kmeans_table));" getResults=t

NOTE. The author of this app is not affiliated with the R project, OpenCPU or Splunk.

Release Notes

Version 1.0.1
Sept. 29, 2016

Subscribe Share

Are you a developer?

As a Splunkbase app developer, you will have access to all Splunk development resources and receive a 10GB license to build an app that will help solve use cases for customers all over the world. Splunkbase has 1000+ apps from Splunk, our partners and our community. Find an app for most any data source and user need, or simply create your own with help from our developer portal.

Follow Us:
Splunk, Splunk>,Turn Data Into Doing, Data-to-Everything, and D2E are trademarks or registered trademarks of Splunk Inc. in the United States and other countries. All other brand names,product names,or trademarks belong to their respective owners.