Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ licenses.json
functional-temp
splunktional-temp

output/
output/
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ clean:
rm -rf venv
rm -rf venv-tools
rm -rf packages/flare/bin/vendor
@unlink "/Applications/Splunk/etc/apps/flare" || true
@find . -type d -name "node_modules" -exec rm -rf {} +
rm -rf output/flare
@rm -f output/flare.tar.gz
Expand Down Expand Up @@ -105,6 +104,5 @@ sl: splunk-local

.PHONY: splunk-local
splunk-local: venv setup-web
@echo "Create symlink from app to Splunk Enterprise and start watching files"
SPLUNK_HOME="/Applications/Splunk" yarn run link
docker compose up -d
yarn run start
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,14 @@ managing and publishing multiple packages in the same repository.


## Development
We use an official splunk docker image for development, by binding the local folder to a folder in the container. In order for this to work, you need to have build the application before starting the docker.

If you have your own Splunk Enterprise installed locally, you can use

```
make splunk-local
```bash
make build
```

to download the required dependencies, watch the file changes to re-compile on the fly and generate a symlink between the Splunk app and the Splunk Enterprise applications folder.
Then you can start the local docker and the frontend runner.

To be able to see your changes when refreshing, add this at the end of this file:
```
File: /Applications/Splunk/etc/system/local/web.conf

[settings]
cacheEntriesLimit = 0
cacheBytesLimit = 0
```bash
make splunk-local
```
Then restart your Splunk Enterprise instance.
15 changes: 15 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
splunk:
image: splunk/splunk:latest
container_name: splunk
platform: linux/amd64
restart: unless-stopped
ports:
- "8000:8000"
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_PASSWORD=a_password
- IS_LOCAL_BUILD=true
volumes:
- ./output/flare:/opt/splunk/etc/apps/flare
- ./splunk/default.yml:/tmp/defaults/default.yml
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"lint": "lerna run lint --no-sort",
"setup": "yarn && lerna run build",
"start": "lerna run start --stream --no-sort --concurrency 100",
"unlink": "cd packages/flare && node build.js unlink",
"link": "cd packages/flare && node build.js unlink && node build.js link",
"test": "cd packages/react-components && yarn run test",
"test:ci": "cd packages/react-components && yarn run test:ci"
},
Expand Down
8 changes: 2 additions & 6 deletions packages/flare/bin/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@
class Logger:
def __init__(self, *, class_name: str) -> None:
splunk_home = os.environ.get("SPLUNK_HOME")
is_local_build = False
log_filepath = ""
if splunk_home:
log_filepath = os.path.join(
splunk_home, "var", "log", "splunk", f"{APP_NAME}.log"
)
application_folder = os.path.join(splunk_home, "etc", "apps", APP_NAME)
is_local_build = os.path.islink(application_folder)
else:
log_filepath = os.path.join(tempfile.gettempdir(), f"{APP_NAME}.log")

self.tag_name = os.path.splitext(os.path.basename(class_name))[0]
self._logger = logging.getLogger(f"flare-{self.tag_name}")

if is_local_build:
# If the application is a symlink, it's been installed locally
self._logger.setLevel(logging.INFO)
if os.environ.get("ENV") == "dev":
self._logger.setLevel(logging.DEBUG)
else:
self._logger.setLevel(logging.ERROR)
formatter = logging.Formatter("%(asctime)s %(levelname)-5s %(message)s")
Expand Down
5 changes: 1 addition & 4 deletions packages/flare/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const shell = require('shelljs');
const OS = require('os').platform().toLocaleLowerCase();

const arg = process.argv[2];
const commands = ['build', 'link', 'unlink'];
const commands = ['build'];

if (!arg) {
shell.echo(
Expand All @@ -22,12 +22,9 @@ if (!commands.includes(arg)) {
const runCommands = {
win32: {
build: () => shell.exec('set NODE_ENV=production&&.\\node_modules\\.bin\\webpack --mode=production'),
link: () => shell.exec('mklink /D "%SPLUNK_HOME%\\etc\\apps\\flare" "%cd%\\..\\..\\output\\flare"'),
},
nix: {
build: () => shell.exec('export NODE_ENV=production && ./node_modules/.bin/webpack --mode=production'),
unlink: () => shell.exec('unlink $SPLUNK_HOME/etc/apps/flare || true'),
link: () => shell.exec('ln -s $PWD/../../output/flare $SPLUNK_HOME/etc/apps/flare'),
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const shell = require('shelljs');
const OS = require('os').platform().toLocaleLowerCase();

const arg = process.argv[2];
const commands = ['build', 'link'];
const commands = ['build'];

if (!arg) {
shell.echo(
Expand Down
9 changes: 9 additions & 0 deletions splunk/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
splunk:
conf:
- key: web
value:
directory: /opt/splunk/etc/system/local
content:
settings:
cacheEntriesLimit: 0
cacheBytesLimit: 0