Skip to content

Commit

Permalink
Merge pull request #2 from ch-bas/update-7.10.0
Browse files Browse the repository at this point in the history
Update The Different Paths
  • Loading branch information
ch-bas authored Jan 28, 2021
2 parents 93e09ff + b05c27a commit 43a0c98
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ Check the [releases](https://github.com/nsano-rururu/elastalert-kibana-plugin/re
[docker-compose sample](https://github.com/nsano-rururu/elastalert-kibana-plugin/wiki/docker-compose-sample)

## 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:
By default the plugin will connect to `localhost:3030`. If your ElastAlert server is running on a different host or port add/change the global environment variables in your configuration file:

```
elastalert-kibana-plugin.serverHost: 123.0.0.1
elastalert-kibana-plugin.serverPort: 9000
PROTOCOL: http
HOSTNAME: localhost
PORT: 3030
```

## Contribution
Expand Down
10 changes: 4 additions & 6 deletions public/components/rules/editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Editor extends Component {

loadRule() {
const { httpClient } = this.props;
httpClient.get(`../api/elastalert/rules/${this.props.rule}`).then(resp => {
httpClient.get(`../rules/${this.props.rule}`).then(resp => {
this.setState({ value: resp.data, ruleName: this.props.rule });
});
}
Expand All @@ -48,11 +48,10 @@ export default class Editor extends Component {
const ruleID = this.props.editorMode === 'edit' ? this.props.rule : this.state.ruleName;

httpClient
.post(`../api/elastalert/rules/${ruleID}`, {
.post(`../rules/${ruleID}`, {
yaml: this.state.value
})
.then(resp => {
if (resp.status === 200) {
.then(() => {
this.setState({ saving: false });
addToast(
'Saved successfully',
Expand All @@ -61,7 +60,6 @@ export default class Editor extends Component {
);
this.closeModal();
loadRules();
}
})
.catch(e => {
this.setState({ saving: false });
Expand All @@ -78,7 +76,7 @@ export default class Editor extends Component {
this.setState({ testing: true, testFailed: null, testResponse: null });

httpClient
.post(`../api/elastalert/test`, {
.post(`../test`, {
rule: this.state.value,
testType: 'schemaOnly'
})
Expand Down
2 changes: 1 addition & 1 deletion public/components/rules/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class List extends Component {
this.setState({ rules: [], selectedRules: [], loading: true });
const { httpClient } = this.props;
httpClient
.get('../api/elastalert/rules')
.get('../rules')
.then(resp => {
this.setState({ rules: resp.data.rules.sort(), error: null, loading: false });
})
Expand Down
2 changes: 1 addition & 1 deletion public/lib/elastalert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const deleteRule = (http, rules, onSuccess, onFail) => {
const rulesCopy = rules.slice();

rules.forEach(rule => {
http.delete(`../api/elastalert/rules/${rule}`)
http.delete(`../rules/${rule}`)
.then(() => {
// Loop through all rules marked for deletion
const index = rulesCopy.indexOf(rule);
Expand Down
15 changes: 11 additions & 4 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function defineRoutes(router: IRouter) {
const uri = process.env.PROTOCOL + '://' + process.env.HOSTNAME + process.env.PORT;
router.get(
{
path: '/api/elastalert/{path}',
path: '/{path}',
validate: false,
},
async (context, req, response) => {
Expand All @@ -25,15 +25,15 @@ export function defineRoutes(router: IRouter) {
);
router.post(
{
path: '/api/elastalert/{path}',
path: '/{path*}',
validate: false,
},
async (context, req, response) => {
const postParams = {
method: 'POST',
body: JSON.stringify({
params: {
index: 'elastalert',
yaml: req.body,
},
}),
};
Expand All @@ -54,10 +54,17 @@ export function defineRoutes(router: IRouter) {
);
router.delete(
{
path: '/api/elastalert/{path}',
path: '/{path*}',
validate: false,
},
async (context, req, response) => {
const deleteRequest = async () => {
return fetch(uri + req.route.path, {
method: 'DELETE',
})
.then((r: any) => console.log(r))
};
await deleteRequest();
return response.ok({
body: {
success: true,
Expand Down

0 comments on commit 43a0c98

Please sign in to comment.