### Install @splunk/visualizations Package Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Provides the command to install the `@splunk/visualizations` package after its peer dependencies have been installed. ```bash npm install @splunk/visualizations ``` -------------------------------- ### Install Project Dependencies with Yarn Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md After generating your Splunk application, install all necessary project dependencies using the yarn setup command. This ensures all packages are correctly linked and ready for development. ```bash yarn setup ``` -------------------------------- ### Install @splunk/ui-utils Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Shows how to install the `@splunk/ui-utils` package, which contains a library of common UI utilities for Splunk applications. ```bash npm install @splunk/ui-utils ``` -------------------------------- ### DataSource setup and teardown Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Details on overriding `setup` and `teardown` methods for Splunk DataSource modules. ```APIDOC ## `setup` and `teardown` The `setup` and `teardown` methods can be called only once per data source. Override these functions to run bootstrap cleanup such as establishing and destroying connections. For example: ```javascript import { DataSource } from '@splunk/datasources'; class MyDataSource extends DataSource { setup() { this.searchJob = this.createSearchJob(); } teardown() { this.searchJob.destroy(); delete this.searchJob; } createSearchJob() { // ... } } ``` ``` -------------------------------- ### Install @splunk/webpack-configs Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Instructions for installing the @splunk/webpack-configs package and its peer dependencies. ```APIDOC ## Install @splunk/webpack-configs ### Description Install the package and its dependencies. ### Steps 1. **Install peer dependencies:** ```bash npm install --save-dev @babel/core@^7 babel-loader@^8 webpack@^4 ``` 2. **Install the package:** ```bash npm install --save-dev @splunk/webpack-configs ``` ``` -------------------------------- ### Install @splunk/search-job with npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/search-job package, which simplifies the creation and access of Splunk search jobs. ```bash npm install @splunk/search-job ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs all necessary project dependencies using Yarn. This command should be run after creating a new Splunk app project. ```bash $ yarn setup ``` -------------------------------- ### Install @splunk/babel-preset Package Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/babel-preset package as a development dependency in your project. This should be done after installing peer dependencies. ```bash npm install --save-dev @splunk/babel-preset ``` -------------------------------- ### Install @splunk/visualizations Peer Dependencies Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Lists the required peer dependencies for installing the `@splunk/visualizations` package, including React, ReactDOM, styled-components, and @splunk/visualization-context. ```bash npm install react@^18 react-dom@^18 styled-components@5 @splunk/visualization-context --save ``` -------------------------------- ### Install @splunk/react-page with npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-page package and its peer dependencies. Requires react, react-dom, and styled-components. ```bash npm install react@^16 react-dom@^16 styled-components@^5 npm install @splunk/react-page ``` -------------------------------- ### Project Setup Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Instructions for setting up your Splunk development environment and creating a new Splunk app and page. ```APIDOC ## Setting up Splunk Home ```bash # Set SPLUNK_HOME to point to the top-level installation directory $ export SPLUNK_HOME=/opt/splunk # Add $SPLUNK_HOME/bin to the shell’s path. $ export PATH=$SPLUNK_HOME/bin:$PATH ``` ## Getting started with @splunk/create To generate files for a Splunk app, run `npx @splunk/create` from an empty project folder. ```bash $ mkdir project-folder $ cd project-folder $ npx @splunk/create #? What do you want to name your Splunk app?: MySplunkApp #? What do you want to name your new page?: MyPage #? What type of page would you like to create?: Add a Basic Page ``` Next, install project dependencies: ```bash $ yarn setup ``` This will create two main directories: * `packages/my-page` * `packages/my-splunk-app` ``` -------------------------------- ### Splunk Demo Setup Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Steps to link your local app to a Splunk instance and run the development server. ```APIDOC ## Splunk demo Splunk demo will allow you to view your new app inside your local Splunk instance: ```bash # navigate to your app folder $ cd packages/my-splunk-app # link the app to your local Splunk instance $ yarn link:app # check that the link is set (optional) $ ls -l $SPLUNK_HOME/etc/apps/my-splunk-app # restart Splunk (will start Splunk if not already started) $ splunk restart # navigate to the root project directory $ cd ../../ # start the Splunk app $ yarn start ``` This will watch both your `my-splunk-app` and `my-page` folders for changes and rebundle. Your app should be visible at `https://localhost:8000`. ``` -------------------------------- ### Install @splunk/react-visualization-utils with npm or yarn Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-visualization-utils package, which provides utilities for visualization data manipulation. ```bash npm install @splunk/react-visualization-utils ``` ```bash yarn add @splunk/react-visualization-utils ``` -------------------------------- ### Start Local React Page Development Demo Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Develop and preview your React page independently from Splunk using the yarn run start:demo command. This command launches a local development server, allowing for faster iteration and hot-reloading of your React components. ```bash # navigate to the page directory cd packages/my-page # start the local development demo yarn run start:demo ``` -------------------------------- ### Example Meta Object Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This snippet shows an example of a Meta object, which provides additional information to the visualization, such as the total count of results and the current search progress. ```javascript { totalCount: 100, // total results progress: 50, // 0-100, current search progress } ``` -------------------------------- ### Splunk DataSource Setup and Teardown Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Demonstrates how to override the `setup` and `teardown` methods within a Splunk DataSource class. These methods are used for one-time bootstrap and cleanup operations, such as establishing and destroying connections. ```javascript import { DataSource } from '@splunk/datasources'; class MyDataSource extends DataSource { setup() { this.searchJob = this.createSearchJob(); } teardown() { this.searchJob.destroy(); delete this.searchJob; } createSearchJob() { // ... } } ``` -------------------------------- ### Install @splunk/time-range-utils Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Provides instructions for installing the `@splunk/time-range-utils` package using npm or yarn. This package offers utilities for time ranges. ```bash npm install @splunk/time-range-utils ``` ```bash yarn add @splunk/time-range-utils ``` -------------------------------- ### Install @splunk/react-sparkline with npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-sparkline package and its peer dependencies. Requires react, react-dom, and styled-components. ```bash npm install react@^16 react-dom@^16 styled-components@^5 npm install @splunk/react-sparkline ``` -------------------------------- ### Install Splunk Webpack Configs Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/webpack-configs package and its peer dependencies using npm. This is the initial step for setting up webpack configurations. ```bash npm install --save-dev @babel/core@^7 babel-loader@^8 webpack@^4 npm install --save-dev @splunk/webpack-configs ``` -------------------------------- ### Install @splunk/react-icons using npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-icons package and its peer dependencies (React, ReactDOM, styled-components). ```bash npm install react@^16 react-dom@^16 styled-components@^5 npm install @splunk/react-icons ``` -------------------------------- ### Install @splunk/eslint-config using npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/eslint-config package and its peer dependencies using npm. ESLint requires peer dependencies to be installed separately. ```bash npm install --save-dev babel-eslint@^10 eslint@^8 eslint-config-airbnb@^19 eslint-plugin-import@^2 eslint-plugin-jsx-a11y@^6 eslint-plugin-react@^7 eslint-plugin-react-hooks@^4 npm install --save-dev @splunk/eslint-config ``` -------------------------------- ### Install @splunk/splunk-utils with npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/splunk-utils package using npm. This package provides a collection of utilities for working with Splunk Enterprise. ```bash npm install @splunk/splunk-utils ``` -------------------------------- ### Install Peer Dependencies for @splunk/babel-preset Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the core Babel dependency required by @splunk/babel-preset. Ensure you have Node.js and npm/yarn installed. ```bash npm install --save-dev @babel/core^7 ``` -------------------------------- ### Install @splunk/react-field-summary using npm or yarn Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-field-summary component, which displays a list of fields from a query and shows a summary panel with common values and statistics. ```bash npm install @splunk/react-field-summary ``` ```bash yarn add @splunk/react-field-summary ``` -------------------------------- ### Install @splunk/react-search with npm or yarn Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-search package, which provides a search bar with time range picker and search button. ```bash npm install @splunk/react-search ``` ```bash yarn add @splunk/react-search ``` -------------------------------- ### Install @splunk/react-toast-notifications with npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-toast-notifications package and its peer dependencies. Requires react and styled-components. ```bash npm install react@^16 styled-components@^5 npm install @splunk/react-toast-notifications ``` -------------------------------- ### Example RequestParams for Data Fetching Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This example demonstrates how to set request parameters to fetch a specific number of results from a data source. It includes the structure for requestParams, data fields, columns, and meta information. ```javascript { requestParams: { offset: 0, count: 20 }, data: { fields: [{ name: 'component' }, { name: 'count' }, { name: 'percent' }], columns: [ [ 'splunkd', 'splunkd_ui_access', 'splunkd_access', 'splunk_web_access', 'scheduler', 'splunk_web_service', ], ['600', '525', '295', '213', '122', '19'], ['87.966380', '50.381304', '60.023780', '121.183272', '70.250513', '90.194752'], ], }, meta: { totalCount: 100 }, } ``` -------------------------------- ### Splunk UI Toolkit Filler Gauge Example Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md An example visualization for a Filler Gauge from the '@splunk/visualizations' package, likely representing a percentage or progress. ```html 02040608010078 ``` -------------------------------- ### Install @splunk/react-events-viewer using npm or yarn Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-events-viewer component, which provides an Events Viewer with options for display style, pagination, and number of events. ```bash npm install @splunk/react-events-viewer ``` ```bash yarn add @splunk/react-events-viewer ``` -------------------------------- ### Example Data Contract Definition Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This example defines a data contract for a visualization, specifying required and optional data sources, as well as initial request parameters for the primary data source. ```javascript const dataContract = { requiredDataSources: [ { name: 'primary', description: 'DataSource that powers the visualization', }, ], optionalDataSources: [ { name: 'annotation', description: 'DataSource that populates event annotations', }, ], initialRequestParams: { primary: { offset: 0, count: 10000 }, }, }; ``` -------------------------------- ### Link and Run Splunk App Locally Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Commands to link a Splunk app to a local Splunk instance, restart Splunk, and start the development server for the app. This allows for viewing and testing the app within a local Splunk environment. ```bash # navigate to your app folder $ cd packages/my-splunk-app # link the app to your local Splunk instance $ yarn link:app # check that the link is set (optional) $ ls -l $SPLUNK_HOME/etc/apps/my-splunk-app # restart Splunk (will start Splunk if not already started) $ splunk restart # navigate to the root project directory $ cd ../.. # start the Splunk app $ yarn start ``` -------------------------------- ### Install @splunk/stylelint-config with npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/stylelint-config package and its peer dependencies using npm. This config provides standardized stylelint rules for Splunk projects. ```bash npm install --save-dev stylelint@^13 npm install --save-dev @splunk/stylelint-config ``` -------------------------------- ### Install @splunk/react-time-range with npm or yarn Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/react-time-range package, which includes time range picker components and supporting utilities. ```bash npm install @splunk/react-time-range ``` ```bash yarn add @splunk/react-time-range ``` -------------------------------- ### Basic Input Field Example Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This snippet demonstrates a basic input field, likely for search queries. It includes a label and a placeholder. No specific libraries or complex dependencies are shown, suggesting a standard HTML input element. ```html ``` -------------------------------- ### Install @splunk/moment using npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/moment package, which provides Moment.js and Moment Timezone plugins for Splunk Enterprise timezones and locale formatting. ```bash npm install @splunk/moment ``` -------------------------------- ### Install @splunk/themes with yarn or npm Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Installs the @splunk/themes package using either yarn or npm. This package contains Splunk theme variables and mixins for use in React and styled-components. ```bash yarn add @splunk/themes npm install @splunk/themes ``` -------------------------------- ### Splunk UI Toolkit Events Data Example Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md An example of how event data is represented in the '@splunk/visualizations' package, showing a table with 'Time' and 'Event' columns, including structured log data. ```json * {[-]Collapse all * datetime: "07-16-2018 16:38:11.545 -0700", * log_level: "INFO", * component: "KVStoreServerStats", * data: {[+]Shift click to expand all} } ``` -------------------------------- ### Object Rest and Spread Properties Example Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md Demonstrates the use of object rest properties to extract remaining properties and object spread syntax to combine objects, facilitated by @babel/plugin-proposal-object-rest-spread. ```javascript let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; // ^-- { a: 3, b: 4 } let n = { x, y, ...z }; // { x: 1, y: 2, a: 3, b: 4 } ``` -------------------------------- ### Static Initial RequestParams Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This example shows a static object defining the initial request parameters, specifying the offset and count for the first data fetch. ```javascript initialRequestParams: { offset: 0, count: 10000, } ``` -------------------------------- ### Splunk UI Toolkit Bar Chart Example Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md A basic example of a Bar chart from the '@splunk/visualizations' package. This chart displays categorical data with one X-axis for components and one Y-axis for a numerical value. ```html ``` -------------------------------- ### Data Contract for Table Visualization Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This data contract example illustrates that the Table visualization only requires a 'primary' data source. It outlines the structure for defining required data sources. ```javascript const dataContract = { requiredDataSources: [ { name: 'primary', description: 'DataSource that powers the visualization', }, ], //... }; ``` -------------------------------- ### Basic Table with Sortable Columns Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This example shows a basic table structure that supports sortable columns. It outlines the user interaction for picking up, moving, and dropping columns to reorder them, along with instructions for canceling the operation. ```html
| Header 1 | Header 2 |
|---|---|
| Data 1.1 | Data 1.2 |
| Data 2.1 | Data 2.2 |
To pick up a sortable column, press space or enter. Use the left and right arrow keys to update the position of the column. Press space or enter again to drop the column in its new position, or press escape to cancel.
``` -------------------------------- ### Data Contract for Line Chart Visualization Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This data contract example shows a Line Chart visualization that requires a 'primary' data source and optionally supports an 'annotation' data source. ```javascript const dataContract = { requiredDataSources: [ { name: 'primary', description: 'DataSource that powers the visualization', }, ], optionalDataSources: [ { name: 'annotation', description: 'DataSource that populates event annotations', }, ], //... }; ``` -------------------------------- ### Dynamic Initial RequestParams Function Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This example defines initial request parameters using a function that takes visualization options and returns an object with offset and count. This allows for dynamic parameter generation based on visualization configuration. ```javascript initialRequestParams: (options = {}) => ({ offset: 0, count: options.count || 20, }) ``` -------------------------------- ### Create a Splunk App with a Basic Page - @splunk/create Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This snippet demonstrates how to use the @splunk/create CLI tool to scaffold a new Splunk app and a basic page. It outlines the prompts the user will encounter during the creation process, including naming the app and the page, and selecting the page type. ```bash #? What do you want to name your Splunk app?: MyTodoListApp #? What do you want to name your new page?: MyTodoListPage #? What type of page would you like to create?: Add a Basic Page ``` -------------------------------- ### Filter DataFrame Fields with frameWithoutInternalFieldsExcept Source: https://github.com/kundeng/splunk-ui-toolkit-doc/blob/docs-only/splunk-ui-kit-complete-docs.md This snippet demonstrates how to use the `frameWithoutInternalFieldsExcept` function within a Splunk UI Toolkit Table component. It filters a DataFrame, removing internal fields (those starting with '_') except for those explicitly listed in the `names` argument. Non-internal fields passed as parameters are ignored. The example shows removing `_raw` while keeping `_time` and `_span`. ```javascript