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

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) 82b5f930adddbe99d8f9b5461ffa29b8b3989d6e27b41c918e56012e6dac78e5
To install your download
For instructions specific to your download, click the Details tab after closing this window.

Flag As Inappropriate

R Analytics

This app has been archived. Learn more about app archiving.
Admins: Please read about Splunk Enterprise 8.0 and the Python 2.7 end-of-life changes and impact on apps and upgradeshere.
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

44
Installs
742
Downloads
Share Subscribe LOGIN TO DOWNLOAD

Subscribe Share

AppInspect Tooling

Splunk AppInspect evaluates Splunk apps against a set of Splunk-defined criteria to assess the validity and security of an app package and components.

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 and add-ons from Splunk, our partners and our community. Find an app or add-on for most any data source and user need, or simply create your own with help from our developer portal.

Follow Us:
© 2005-2020 Splunk Inc. All rights reserved.
Splunk®, Splunk>®, Listen to Your Data®, The Engine for Machine Data®, Hunk®, Splunk Cloud™, Splunk Light™, SPL™ and Splunk MINT™ are trademarks and 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.