Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP :- Setup pages refactor #31

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 78 additions & 66 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,79 @@
version: '3.6'

services:
splunk:
image: "splunk/splunk:latest"
container_name: splunk-app-examples
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
- SPLUNK_PASSWORD=changed!
ports:
- "8000:8000"
- "8088:8088"
- "8089:8089"
volumes:
# Weather App
- ./setup_pages/weather_app_example:/opt/splunk/etc/apps/weather_app_example
- ./lib:/opt/splunk/etc/apps/weather_app_example/vendor

# Dependency checking app example
- ./setup_pages/dependency_checking_app_example:/opt/splunk/etc/apps/dependency_checking_app_example
- ./lib:/opt/splunk/etc/apps/dependency_checking_app_example/vendor

# Setup page simple
- ./setup_pages/setup_page_simple:/opt/splunk/etc/apps/setup_page_simple

# Custom search commands app
- ./custom_search_commands/python/customsearchcommands_app/package:/opt/splunk/etc/apps/customsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/customsearchcommands_app/lib/splunklib

# Eventing commands app
- ./custom_search_commands/python/eventingsearchcommands_app:/opt/splunk/etc/apps/eventingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/eventingsearchcommands_app/lib/splunklib

# Generating commands app
- ./custom_search_commands/python/generatingsearchcommands_app:/opt/splunk/etc/apps/generatingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/generatingsearchcommands_app/lib/splunklib

# Reporting commands app
- ./custom_search_commands/python/reportingsearchcommands_app:/opt/splunk/etc/apps/reportingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/reportingsearchcommands_app/lib/splunklib

# Streaming commands app
- ./custom_search_commands/python/streamingsearchcommands_app:/opt/splunk/etc/apps/streamingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/streamingsearchcommands_app/lib/splunklib

# GitHub commits
- ./modularinputs/python/github_commits:/opt/splunk/etc/apps/github_commits
- ./lib/splunklib:/opt/splunk/etc/apps/github_commits/lib/splunklib

# GitHub forks
- ./modularinputs/python/github_forks:/opt/splunk/etc/apps/github_forks
- ./lib/splunklib:/opt/splunk/etc/apps/github_forks/lib/splunklib

# Random numbers
- ./modularinputs/python/random_numbers:/opt/splunk/etc/apps/random_numbers
- ./lib/splunklib:/opt/splunk/etc/apps/random_numbers/lib/splunklib

# Twitted
- ./python/twitted/twitted:/opt/splunk/etc/apps/twitted
- ./lib/splunklib:/opt/splunk/etc/apps/twitted/lib/splunklib

healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
interval: 5s
timeout: 5s
version: '3.6'

services:
splunk:
image: "splunk/splunk:latest"
container_name: splunk-app-examples
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
- SPLUNK_PASSWORD=changed!
ports:
- "8000:8000"
- "8088:8088"
- "8089:8089"
volumes:
# Weather App
- ./setup_pages/weather_app_example:/opt/splunk/etc/apps/weather_app_example
- /opt/splunk/etc/apps/weather_app_example/node_modules
- ./lib:/opt/splunk/etc/apps/weather_app_example/vendor

# Dependency checking app example
- ./setup_pages/dependency_checking_app_example:/opt/splunk/etc/apps/dependency_checking_app_example
- /opt/splunk/etc/apps/dependency_checking_app_example/node_modules
- ./lib:/opt/splunk/etc/apps/dependency_checking_app_example/vendor

# React Setup Page
- ./setup_pages/react_setup_page_example:/opt/splunk/etc/apps/react_setup_page_example
- /opt/splunk/etc/apps/react_setup_page_example/node_modules

# Developer Guidance App
- ./setup_pages/developer_guidance_setup_page:/opt/splunk/etc/apps/developer_guidance_setup_page
- /opt/splunk/etc/apps/developer_guidance_setup_page/node_modules
- ./lib:/opt/splunk/etc/apps/developer_guidance_setup_page/vendor

# Setup page simple
- ./setup_pages/setup_page_simple:/opt/splunk/etc/apps/setup_page_simple
- /opt/splunk/etc/apps/setup_page_simple/node_modules

# Custom search commands app
- ./custom_search_commands/python/customsearchcommands_app/package:/opt/splunk/etc/apps/customsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/customsearchcommands_app/lib/splunklib

# Eventing commands app
- ./custom_search_commands/python/eventingsearchcommands_app:/opt/splunk/etc/apps/eventingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/eventingsearchcommands_app/lib/splunklib

# Generating commands app
- ./custom_search_commands/python/generatingsearchcommands_app:/opt/splunk/etc/apps/generatingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/generatingsearchcommands_app/lib/splunklib

# Reporting commands app
- ./custom_search_commands/python/reportingsearchcommands_app:/opt/splunk/etc/apps/reportingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/reportingsearchcommands_app/lib/splunklib

# Streaming commands app
- ./custom_search_commands/python/streamingsearchcommands_app:/opt/splunk/etc/apps/streamingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/streamingsearchcommands_app/lib/splunklib

# GitHub commits
- ./modularinputs/python/github_commits:/opt/splunk/etc/apps/github_commits
- ./lib/splunklib:/opt/splunk/etc/apps/github_commits/lib/splunklib

# GitHub forks
- ./modularinputs/python/github_forks:/opt/splunk/etc/apps/github_forks
- ./lib/splunklib:/opt/splunk/etc/apps/github_forks/lib/splunklib

# Random numbers
- ./modularinputs/python/random_numbers:/opt/splunk/etc/apps/random_numbers
- ./lib/splunklib:/opt/splunk/etc/apps/random_numbers/lib/splunklib

# Twitted
- ./python/twitted/twitted:/opt/splunk/etc/apps/twitted
- ./lib/splunklib:/opt/splunk/etc/apps/twitted/lib/splunklib

healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
interval: 5s
timeout: 5s
retries: 20
4 changes: 2 additions & 2 deletions javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "Splunk test examples",
"main": "test_examples.js",
"dependencies": {
"splunk-sdk": ">=1.4.0",
"needle": "3.0.0"
"needle": "3.0.0",
"splunk-sdk": "^1.12.1"
},
"devDependencies": {
"browserify": "^17.0.0",
Expand Down
72 changes: 36 additions & 36 deletions setup_pages/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# Overview of setup pages

A setup page is a page in your app that displays the first time your users launch the app. The setup page allows your users to configure app settings in Splunk Web.

In Splunk Cloud Platform, you must provide a setup page for app configuration. In Splunk Enterprise, you can provide a setup page as a best practice for app configuration.

## Use cases for setup pages

Here are some use cases for setup pages.

* You want to save user-provided configurations in a custom configuration (.conf) file in your app.
* You want to integrate your app with an external service, such as a third-party API.
* You want to check whether your app's dependencies are installed.

## Workflow for creating a setup page

Follow this workflow to create a setup page.

1. Write the JavaScript code to configure your app.
2. Create a Simple XML dashboard to surface the JavaScript code in your app's UI.
3. Update your app's app.conf file to add the setup page to your app configuration.

## Setup page examples

This repository contains the following examples to help you get started creating setup pages.

| Example | Description |
|---------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| dependency_checking_app_example | Uses a setup page to verify the installation of app dependencies |
| developer_guidance_setup_page | Demonstrates how to use a setup page that adheres to Splunk Application Certification standards |
| react_setup_page_example | Demonstrates how to configure a setup page using React |
| setup_page_simple | Uses a setup page to store an encrypted credential with the storage/passwords endpoint using the Splunk SDK for Javascript |
| weather_app_example | Uses a setup page to call an external API |

## See also

# Overview of setup pages
A setup page is a page in your app that displays the first time your users launch the app. The setup page allows your users to configure app settings in Splunk Web.
In Splunk Cloud Platform, you must provide a setup page for app configuration. In Splunk Enterprise, you can provide a setup page as a best practice for app configuration.
## Use cases for setup pages
Here are some use cases for setup pages.
* You want to save user-provided configurations in a custom configuration (.conf) file in your app.
* You want to integrate your app with an external service, such as a third-party API.
* You want to check whether your app's dependencies are installed.
## Workflow for creating a setup page
Follow this workflow to create a setup page.
1. Write the JavaScript code to configure your app.
2. Create a Simple XML dashboard to surface the JavaScript code in your app's UI.
3. Update your app's app.conf file to add the setup page to your app configuration.
## Setup page examples
This repository contains the following examples to help you get started creating setup pages.
| Example | Description |
|---------------------------------|----------------------------------------------------------------------------------------------------------------------------|
| dependency_checking_app_example | Uses a setup page to verify the installation of app dependencies |
| developer_guidance_setup_page | Demonstrates how to use a setup page that adheres to Splunk Application Certification standards |
| react_setup_page_example | Demonstrates how to configure a setup page using React |
| setup_page_simple | Uses a setup page to store an encrypted credential with the storage/passwords endpoint using the Splunk SDK for Javascript |
| weather_app_example | Uses a setup page to call an external API |
## See also
* [Enable first-run configuration with setup pages in Splunk Cloud Platform or Splunk Enterprise](https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/setuppage) in the Splunk *Developer Guide*
108 changes: 62 additions & 46 deletions setup_pages/dependency_checking_app_example/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,62 @@
# Overview

This is an example Splunk App that demonstrates how to use a setup page to check for the installation of app dependencies. This example adheres to Splunk Application Certification standards.

This app requires that users configure the weather app as a dependency in order to complete the setup process. The setup page checks whether the dependent app is configured and updated to a specific version before allowing users to access the app home page.

# Setup Page Entry Point

Splunk will automatically try to redirect the user to the setup page if the `app.conf`'s `[install]` stanza has its `is_configured` property set to false.

# Program Flow

This program starts in the `app.conf`, where the `[install]` stanza's `is_configured` property is set to `false`. This causes Splunk to redirect to it's setup page that is specified so that an admin/user can configure it for use.

In the `app.conf`'s, `[ui]` stanza there is a `setup_page` property that points to which resource should be used for the setup page. In this case it's pointing to `default/data/ui/views/setup_page_dashboard.xml`.

The dashboard view specifies its CSS and JavaScript resources and points to `appserver/static/javascript/setup_page.js`.

And finally the `setup_page.js` imports a React app from `appserver/static/javascript/views/app.js`.

There are two apps installed out-of-the-box when you `make` examples repo. Both not configured to begin with. Follow these steps to run through the dependency_checking_setup_page_app example:
- First navigate to the dependency_checking_app and attempt to configure.
- There will be an alert that the `Weather_app_example` is not configured.
- Navigate to the `weather_app_example` and finish set up configuration. Ensure the version installed is greater or equal to 1.0.
- Navigate back to the dependency_checking_app and attempt to configure.
- Set up configuration should complete successfully.


# Resources
- Splunk Techniques Used
- Splunk Dashboards
- [API Documentation](http://docs.splunk.com/Documentation/SplunkCloud/latest/Viz/PanelreferenceforSimplifiedXML) (docs.splunk.com)
- Splunk Setup Page
- [app.conf Specification](http://docs.splunk.com/Documentation/Splunk/6.6.3/admin/Appconf#.5Bui.5D)
- Splunk Web Framework
- [Main Website](https://dev.splunk.com/enterprise/docs/developapps/webframework) (dev.splunk.com)
- Technology Used
- CSS
- HTML
- JavaScript
- React
- [Main Website](https://reactjs.org/)
- [On GitHub](https://github.com/facebook/react)
- Splunk JavaScript Software Development Kit
- [Main Website](https://dev.splunk.com/enterprise/docs/javascript/sdk-javascript) (dev.splunk.com)
- [On GitHub](https://github.com/splunk/splunk-sdk-javascript)
# Overview

This is an example Splunk App that demonstrates how to use a setup page to check for the installation of app dependencies. This example adheres to Splunk Application Certification standards.

This app requires that users configure the weather app as a dependency in order to complete the setup process. The setup page checks whether the dependent app is configured and updated to a specific version before allowing users to access the app home page.

# Setup Page Entry Point

Splunk will automatically try to redirect the user to the setup page if the `app.conf`'s `[install]` stanza has its `is_configured` property set to false.

# Program Flow

This program starts in the `app.conf`, where the `[install]` stanza's `is_configured` property is set to `false`. This causes Splunk to redirect to it's setup page that is specified so that an admin/user can configure it for use.

In the `app.conf`'s, `[ui]` stanza there is a `setup_page` property that points to which resource should be used for the setup page. In this case it's pointing to `default/data/ui/views/setup_page_dashboard.xml`.

The dashboard view specifies its CSS and JavaScript resources and points to the two files in `appserver/static/javascript/app.js`(this will be generated after the build command specified in the installation steps below) and `appserver/static/styles/setup_page.css`.

And finally the `app.js` imports a React app inside dashboard view.

# Installation
- First users have to install dependencies by running `npm install` command in the root directory of the application.

- Then, inside `src` directory, user can write their own code.

- Run `npm run build` command. It will bundle all the files of the `src` directory and will save the whole bundle in `appserver/static/javascript` as `app.js`.

- Now run the `splunk-app-examples` docker container.

*Note:* You can also copy files using `docker cp ./setup_pages/dependency_checking_app_example CONTAINER:/opt/splunk/etc/apps/dependency_checking_app_example`

# Configuration
There are two apps installed out-of-the-box when you `make` examples repo. Both not configured to begin with. Follow these steps to run through the dependency_checking_setup_page_app example:

- Navigate to the "Dependency Checking App Example" and attempt to configure.

- There will be an alert that the `Weather_app_example` is not configured.

- Navigate to the `weather_app_example` and finish the configuration. Ensure the version installed is greater or equal to 1.0.

- Navigate back to the "Dependency Checking App Example" and attempt to configure.

- Set up configuration should complete successfully.

# Resources
- Splunk Techniques Used
- Splunk Dashboards
- [API Documentation](http://docs.splunk.com/Documentation/SplunkCloud/latest/Viz/PanelreferenceforSimplifiedXML) (docs.splunk.com)
- Splunk Setup Page
- [app.conf Specification](http://docs.splunk.com/Documentation/Splunk/6.6.3/admin/Appconf#.5Bui.5D)
- Splunk Web Framework
- [Main Website](https://dev.splunk.com/enterprise/docs/developapps/webframework) (dev.splunk.com)
- Technology Used
- CSS
- HTML
- JavaScript
- React
- [Main Website](https://reactjs.org/)
- [On GitHub](https://github.com/facebook/react)
- Splunk JavaScript Software Development Kit
- [Main Website](https://dev.splunk.com/enterprise/docs/javascript/sdk-javascript) (dev.splunk.com)
- [On GitHub](https://github.com/splunk/splunk-sdk-javascript)
Loading