Skip to content

Commit

Permalink
Alpha release rewritten plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnrondeel committed Aug 13, 2018
1 parent ea1a46a commit e003f30
Show file tree
Hide file tree
Showing 26 changed files with 4,706 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
extends: "@elastic/kibana"

settings:
import/resolver:
'@elastic/eslint-import-resolver-kibana':
rootPackageName: 'elastalert-kibana-plugin'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
npm-debug.log*
node_modules
/build/
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Development

See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment. Once you have completed that, git clone our plugin into a folder next to your cloned kibana folder. Once that is done you can use the commands below.

- `yarn kbn bootstrap`

Install dependencies and crosslink Kibana and all projects/plugins.

- `yarn start`

Start kibana and have it include this plugin. You can pass any arguments that you would normally send to `bin/kibana`

```bash
yarn start --elasticsearch.url http://localhost:9220
```

- `yarn build`

Build a distributable archive of the plugin.

- `yarn test:browser`

Run the browser tests in a real web browser.

- `yarn test:server`

Run the server tests using mocha.

For more information about any of these commands run `yarn ${task} --help`. For a full list of tasks checkout the `package.json` file, or run `yarn run`.

## Releasing

In the develop branch the Kibana version in `package.json` should always point to the latest unreleased stable version. For example: if Kibana 6.3.2 has been released the version should be 6.3.3.

The develop branch is merged to master when a new version is ready (do not forget to increment the version inside `package.json`). The new version is tagged and uploaded to GitHub releases.

A GitHub release should at least contain a build for the latest stable Kibana version, but if possible builds for older minor versions should be created as well. Building for a specific Kibana version can be done easily with: `yarn build -k kibana-version-here`.
28 changes: 13 additions & 15 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
The 3-clause BSD license (Modified)
===================================
# The 3-clause BSD license (Modified)

Copyright © 2016, BitSensor B.V.
Copyright © 2018, BitSensor B.V.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of BitSensor, BitSensor B.V. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
However, those names can be used when explicitely stating the use of
the ElastAlert Server Plugin (which can be rephrased as the Alerting
Plugin).
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of BitSensor, BitSensor B.V. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
However, those names can be used when explicitly stating the use of
the ElastAlert Kibana Plugin.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Expand All @@ -27,4 +25,4 @@ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# ElastAlert Kibana plugin
![img](https://raw.githubusercontent.com/bitsensor/elastalert-kibana-plugin/master/kibana-elastalert-plugin-showcase.gif)
# ElastAlert Kibana Plugin

> This plugin provides a way to create, test and edit ElastAlert rules within Kibana.
![Showcase](showcase.gif)

---

## Requirements
- Our [ElastAlert](https://github.com/bitsensor/elastalert) fork
- Kibana 6.3.1 or higher

## Installation
Check the installation guide inside the branch that matches your Kibana version.
Check the [releases](https://github.com/bitsensor/elastalert-kibana-plugin/releases) page to download and install the latest version of this plugin that is compatible with your Kibana version.

## Configuration
By default the plugin will connect to `localhost:3030`. If your ElastAlert server is running on a different host or port add/change the following options in your `config/kibana.yml` file:

```
elastalert-kibana-plugin.serverHost: 123.0.0.1
elastalert-kibana-plugin.serverPort: 9000
```

- [Kibana 4.6.6](https://github.com/bitsensor/elastalert-kibana-plugin/tree/4.6.6)
- [Kibana 5.6.8](https://github.com/bitsensor/elastalert-kibana-plugin/tree/5.6.8)
- [Kibana 6.2.3](https://github.com/bitsensor/elastalert-kibana-plugin/tree/6.2.3) (experimental)
## Contribution
Please report any issues or suggestions you have on the [issues page](https://github.com/bitsensor/elastalert-kibana-plugin/issues). If you want to create a pull request please check our [contribution guide](CONTRIBUTING.md).
29 changes: 29 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import elastAlertAPI from './server/routes/elastalert';

export default function (kibana) {
return new kibana.Plugin({
name: 'elastalert-kibana-plugin',
uiExports: {
app: {
title: 'ElastAlert',
description: 'A way to create, test and edit ElastAlert rules within Kibana.',
main: 'plugins/elastalert-kibana-plugin/app'
}
},
config(Joi) {
return Joi.object({
enabled: Joi.boolean().default(true),
serverHost: Joi.string()
.hostname()
.default('localhost'),
serverPort: Joi.number()
.integer()
.default(3030),
serverSsl: Joi.boolean().default(false)
}).default();
},
init(server, options) {
elastAlertAPI(server, options);
}
});
}
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "elastalert-kibana-plugin",
"version": "1.0.0-alpha.1",
"description": "Create, test and edit ElastAlert rules within Kibana.",
"main": "index.js",
"license": "SEE LICENSE IN LICENSE.md",
"kibana": {
"version": "6.3.3",
"templateVersion": "1.0.0"
},
"scripts": {
"preinstall": "node ../kibana/preinstall_check",
"kbn": "node ../kibana/scripts/kbn",
"lint": "eslint .",
"start": "plugin-helpers start",
"test:server": "plugin-helpers test:server",
"test:browser": "plugin-helpers test:browser",
"build": "plugin-helpers build"
},
"devDependencies": {
"@elastic/eslint-config-kibana": "link:../kibana/packages/eslint-config-kibana",
"@elastic/eslint-import-resolver-kibana": "link:../kibana/packages/kbn-eslint-import-resolver-kibana",
"@kbn/plugin-helpers": "link:../kibana/packages/kbn-plugin-helpers",
"babel-eslint": "^8.0.2",
"eslint": "^4.11.0",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jest": "^21.3.2",
"eslint-plugin-mocha": "^4.9.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-react": "^7.0.1",
"expect.js": "^0.3.1"
},
"dependencies": {
"@elastic/eui": "^3.5.1"
}
}
34 changes: 34 additions & 0 deletions public/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { uiModules } from 'ui/modules';
import chrome from 'ui/chrome';
import { render, unmountComponentAtNode } from 'react-dom';
import 'ui/autoload/styles';
import { Main } from './components/main';

const app = uiModules.get('apps/elastalertKibanaPlugin');

app.config($locationProvider => {
$locationProvider.html5Mode({
enabled: false,
requireBase: false,
rewriteLinks: false
});
});

app.config(stateManagementConfigProvider =>
stateManagementConfigProvider.disable()
);

function RootController($scope, $element, $http) {
const domNode = $element[0];

// render react to DOM
render(<Main title="ElastAlert Kibana Plugin" httpClient={$http} />, domNode);

// unmount react on controller destroy
$scope.$on('$destroy', () => {
unmountComponentAtNode(domNode);
});
}

chrome.setRootController('elastalertKibanaPlugin', RootController);
14 changes: 14 additions & 0 deletions public/components/console/console.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { EuiCallOut } from '@elastic/eui';

export const Console = (props) => (
<EuiCallOut
size="s"
title="Console output"
iconType="console"
color={props.hasError ? 'danger' : 'success'}
style={{ whiteSpace: 'pre-wrap' }}
>
{props.consoleOutput}
</EuiCallOut>
);
2 changes: 2 additions & 0 deletions public/components/console/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { Console } from './console';
export { Console };
1 change: 1 addition & 0 deletions public/components/main/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Main } from './main';
47 changes: 47 additions & 0 deletions public/components/main/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import {
EuiPage,
EuiPageHeader,
EuiPageHeaderSection,
EuiTitle,
EuiPageBody,
EuiButtonIcon,
EuiToolTip
} from '@elastic/eui';
import '@elastic/eui/dist/eui_theme_light.css';
import { StatusToast } from '../toast';
import List from '../rules/list/list';

export const Main = (props) => (
<React.Fragment>
<StatusToast />
<EuiPage>
<EuiPageBody>
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>{props.title}</h1>
</EuiTitle>
</EuiPageHeaderSection>
<EuiPageHeaderSection>
<EuiToolTip position="left" content="Source @ GitHub">
<EuiButtonIcon
size="s"
color="text"
onClick={() =>
window.open(
'https://github.com/bitsensor/elastalert-kibana-plugin',
'_blank'
)
}
iconType="logoGithub"
aria-label="Github"
/>
</EuiToolTip>
</EuiPageHeaderSection>
</EuiPageHeader>
<List httpClient={props.httpClient} />
</EuiPageBody>
</EuiPage>
</React.Fragment>
);
63 changes: 63 additions & 0 deletions public/components/modal/dangerous.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React, { Component } from 'react';
import {
EuiButton,
EuiConfirmModal,
EuiOverlayMask,
EUI_MODAL_CONFIRM_BUTTON
} from '@elastic/eui';

export default class Dangerous extends Component {
constructor(props) {
super(props);

this.state = {
isDestroyModalVisible: false
};
}

closeDestroyModal = () => {
this.setState({ isDestroyModalVisible: false });
};

showDestroyModal = () => {
this.setState({ isDestroyModalVisible: true });
};

action = () => {
this.props.action(this);
}

render() {
let destroyModal;

if (this.state.isDestroyModalVisible) {
destroyModal = (
<EuiOverlayMask>
<EuiConfirmModal
title={this.props.title}
onCancel={this.closeDestroyModal}
onConfirm={this.action}
cancelButtonText="No, don't do it"
confirmButtonText="Yes, do it"
buttonColor="danger"
defaultFocusedButton={EUI_MODAL_CONFIRM_BUTTON}
>
<p>
{this.props.text}
</p>
<p>Are you sure you want to do this?</p>
</EuiConfirmModal>
</EuiOverlayMask>
);
}

return (
<div>
<EuiButton color="danger" fill onClick={this.showDestroyModal}>
{this.props.buttonText}
</EuiButton>
{destroyModal}
</div>
);
}
}
2 changes: 2 additions & 0 deletions public/components/modal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Dangerous from './dangerous';
export { Dangerous };
Loading

0 comments on commit e003f30

Please sign in to comment.