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

search something relevant into a Service/subservice in Splunk #197

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cde610f
add splunk handler
AlvaroVega Mar 6, 2019
de37b1e
add splunkoperations
AlvaroVega Mar 6, 2019
addfffb
fix relevant
AlvaroVega Mar 6, 2019
dc69fe5
upgrade license file
AlvaroVega Mar 6, 2019
65dfdf6
fix splunk startup
AlvaroVega Mar 6, 2019
62885cc
add splunk options to entrypoint
AlvaroVega Mar 7, 2019
90491f4
fix conf for relevant info
AlvaroVega Mar 7, 2019
251963f
fix query to splunk
AlvaroVega Mar 7, 2019
4cd05e7
add component and customtext
AlvaroVega Mar 7, 2019
1170cf8
update apiary
AlvaroVega Mar 7, 2019
bc5dd93
update apiary
AlvaroVega Mar 7, 2019
f036071
update CNR
AlvaroVega Mar 7, 2019
e1e9815
add correlator and transaction
AlvaroVega Mar 8, 2019
51cf17f
fix schema validator
AlvaroVega Mar 8, 2019
a350a06
update apiary
AlvaroVega Mar 8, 2019
ad596fa
update doc
AlvaroVega Mar 8, 2019
2f6ffbb
fix input names
AlvaroVega Mar 8, 2019
95d9e0b
raise exception if not admin token
AlvaroVega Mar 8, 2019
6612bd5
fix entry result parsing
AlvaroVega Mar 8, 2019
e0ee7af
fix schema for relevant info
AlvaroVega Mar 11, 2019
59a516d
add validation for COMPONENT
AlvaroVega Mar 11, 2019
4ec1523
fix schema
AlvaroVega Mar 11, 2019
3652355
show only 10 items at most
AlvaroVega Mar 11, 2019
c88ebc3
simplify component arg
AlvaroVega Mar 12, 2019
d07f10f
simplify api flow
AlvaroVega Mar 12, 2019
ab56f68
fix urls
AlvaroVega Mar 12, 2019
add4baf
add docker args
AlvaroVega Mar 13, 2019
3088cf2
fix check about splunk
AlvaroVega Mar 14, 2019
9dd88e1
add ctxmboard-gasnatural
AlvaroVega Mar 14, 2019
fd7f203
Update splunk.py
AlvaroVega Mar 14, 2019
a671f0c
Merge branch 'master' into task/add_splunk_for_revelant_info
AlvaroVega Mar 15, 2019
c91edcd
update apiary
AlvaroVega Mar 18, 2019
704818c
add extra components
AlvaroVega Mar 18, 2019
c84b64e
Merge branch 'task/add_splunk_for_revelant_info' of github.com:telefo…
AlvaroVega Mar 18, 2019
0ea0297
fix typo
AlvaroVega Mar 18, 2019
b5aa9c6
fix flow id in log
AlvaroVega Mar 18, 2019
32eb220
fix default conf
AlvaroVega Mar 18, 2019
e44c504
fix default conf values
AlvaroVega Mar 18, 2019
838f95d
replace get by post
AlvaroVega Mar 19, 2019
b673681
add get method
AlvaroVega Mar 19, 2019
ef0cf6e
allow SubServiceAdmin role for isTokenAdmin
AlvaroVega Mar 20, 2019
bd2702e
fix arg
AlvaroVega Mar 20, 2019
b270c72
fix bypass get -> post
AlvaroVega Mar 20, 2019
f4466fa
update statistics
AlvaroVega Mar 20, 2019
3f95bea
update statistics
AlvaroVega Mar 20, 2019
8ea4bc7
Merge branch 'master' into task/add_splunk_for_revelant_info
AlvaroVega Apr 1, 2019
4266a62
Merge branch 'master' into task/add_splunk_for_revelant_info
AlvaroVega Apr 3, 2019
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
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CHANGES
=======

ADD: search about something relevant in a Service/subservice into Splunk (#196)
ADD: Allow subservices names with '-'
ADD: anon passwords in debug logs
ADD: extra check for getUserDetailsByAdmin to create response
Expand Down
4 changes: 4 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ As you can see there are several arguments to pass to orchestrator entry point i
-cygnushost <value>
-mailerhost <value>
-ldaphost <value>
-splunkhost <value>
-keystoneport <value>
-keypassport <value>
-orionport <value>
Expand All @@ -55,12 +56,15 @@ As you can see there are several arguments to pass to orchestrator entry point i
-cygnusport <value>
-ldapport <value>
-mailerport <value>
-splunkport <value>
-ldapbasedn <value>
-maileruser <value>
-mailerpasswd <value>
-mailerfrom <value>
-mailerto <value>
-mongodburi <value>
-splunkuser <value>
-splunkpasswd <value>
```


Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ ENV MAILER_TO smtpto

ENV MONGODB_URI localhost:27017

ENV SPLUNK_HOST localhost
ENV SPLUNK_PORT 8089
ENV SPLUNK_PROTOCOL https
ENV SPLUNK_USER splkuser
ENV SPLUNK_PASSWORD splkpass


ENV PEP_PASSWORD pep
ENV IOTAGENT_PASSWORD iotagent

Expand Down Expand Up @@ -146,6 +153,14 @@ RUN \
\"to\": \"'$MAILER_TO'\" \
}/g' /opt/orchestrator/settings/dev.py && \

sed -i ':a;N;$!ba;s/SPLUNK = {[A-Za-z0-9,=@.\-\/\"\n: ]*}/SPLUNK = { \
\"protocol\": \"'$SPLUNK_PROTOCOL'\", \
\"host\": \"'$SPLUNK_HOST'\", \
\"port\": \"'$SPLUNK_PORT'\", \
\"user\": \"'$SPLUNK_USER'\", \
\"password\": \"'$SPLUNK_PASSWORD'\" \
}/g' /opt/orchestrator/settings/dev.py && \

sed -i ':a;N;$!ba;s/MONGODB = {[A-Za-z0-9,\/\"\n: ]*}/MONGODB = { \
\"URI\": \"mongodb:\/\/'$MONGODB_URI'\" \
}/g' /opt/orchestrator/settings/dev.py && \
Expand Down Expand Up @@ -178,6 +193,11 @@ RUN \
sed -i 's/MAILER_FROM=smtpuser/MAILER_FROM='$MAILER_FROM'/g' /opt/orchestrator/bin/orchestrator-entrypoint.sh && \
sed -i 's/MAILER_TO=smtpuser/MAILER_TO='$MAILER_TO'/g' /opt/orchestrator/bin/orchestrator-entrypoint.sh && \
sed -i 's/MONGODB_URI=localhost:27017/MONGODB_URI='$MONGODB_URI'/g' /opt/orchestrator/bin/orchestrator-entrypoint.sh && \
sed -i 's/SPLUNK_HOST=localhost/SPLUNK_HOST='$SPLUNK_HOST'/g' /opt/orchestrator/bin/orchestrator-entrypoint.sh && \
sed -i 's/SPLUNK_PORT=587/SPLUNK_PORT='$SPLUNK_PORT'/g' /opt/orchestrator/bin/orchestrator-entrypoint.sh && \
sed -i 's/SPLUNK_PROTOCOL=https/SPLUNK_PROTOCOL='$SPLUNK_PROTOCOL'/g' /opt/orchestrator/bin/orchestrator-entrypoint.sh && \
sed -i 's/[email protected]/SPLUNK_USER='$SPLUNK_USER'/g' /opt/orchestrator/bin/orchestrator-entrypoint.sh && \
sed -i 's/SPLUNK_PASSWORD=yourpassword/SPLUNK_PASSWORD='$SPLUNK_PASSWORD'/g' /opt/orchestrator/bin/orchestrator-entrypoint.sh && \
# Put orchestrator version
sed -i 's/ORC_version/'$ORCHESTRATOR_VERSION'/g' /opt/orchestrator/settings/common.py && \
sed -i 's/\${project.version}/'$ORCHESTRATOR_VERSION'/g' /opt/orchestrator/orchestrator/core/banner.txt && \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Orchestrator is used to:
- Activate / deactivate IoT Modules
- Retrieve statistics and metrics about API usage
- Create, List, Modify LDAP Users
- Search for something relevant in a service (or subservice)

Orchestrator is based mainly on:
- Python 2.7 needed
Expand All @@ -41,6 +42,7 @@ Orchestrator relies on these other IoT parts:
- OpenLDAP (optional)
- Mailer (optional)
- MongoDB (optional)
- Splunk (optional)

Some of these IoT parts are optional, this means that orchestrator can work without them but excluding the part of feature in which are involved. This way Keystone and Keypass are mandatory to deal with Orchestrator.

Expand Down
102 changes: 101 additions & 1 deletion apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,62 @@ In the cases where "serviceId" is part of URL "SERVICE_NAME" field at body can b
}


## Activate IoT Module in a Service [/v1.0/service/{serviceId}/module_activation/{iot_module}]

### list activated IoT Modules [GET]
+ Parameters
+ serviceId (required, `string`) ... Service Id
+ Request (application/json)
{
"SERVICE_NAME":"test_service",
"SERVICE_USER_NAME":"test_admin_service",
"SERVICE_USER_PASSWORD":"passwd",
"SERVICE_USER_TOKEN":"token",
}
+ Response 200 (application/json)
+ Body
{
"activated_modules": [ {"name": "STH", "subscriptionid": "23423435", "alias": "HISTORIC"},
{"name": "PERSEO", "subscriptionid": "34243434", "alias": "RULES"} ]
}

### activate an IoT Module [POST]
+ Parameters
+ serviceId (required, `string`) ... Service Id
+ iot_module (optional, `string`) ... IOTModule
+ Request (application/json)
{
"SERVICE_NAME":"test_service",
"SERVICE_USER_NAME":"test_admin_service",
"SERVICE_USER_PASSWORD":"passwd",
"SERVICE_USER_TOKEN":"token",
"IOTMODULE":"STH"
}
Required: [ "iot_module/IOTMODULE" ]
+ Response 201 (application/json)
+ Body
{
"subscriptionid": "23423435"
}

### deactivate an IoT Module [DELETE]
+ Parameters
+ serviceId (required, `string`) ... Service id
+ iot_module (optional, `string`) ... IOTModule
+ Request (application/json)
{
"SERVICE_NAME":"test_service",
"SERVICE_USER_NAME":"test_admin_service",
"SERVICE_USER_PASSWORD":"passwd",
"SERVICE_USER_TOKEN":"token",
"IOTMODULE":"STH"
}
Required: [ "iot_module/IOTMODULE" ]
+ Response 204

## Activate IoT Module in a Sub-service of service [/v1.0/service/{serviceId}/subservice/{subserviceId}/module_activation/{iot_module}]

### list activated IoT Modules [POST]
### list activated IoT Modules [GET]
+ Parameters
+ serviceId (required, `string`) ... Service Id
+ subserviceId (required, `string`) ... SubService Id
Expand Down Expand Up @@ -1199,3 +1252,50 @@ The following metrics are collected by the component:
{
"details": "OK"
}

## Search something relevant about a Service in Splunk [/v1.0/service/{serviceId}/relevant/{component}]

### Search something relevant about a Service [POST]
+ Parameters
+ serviceId (required, `string`) ... Service Id
+ COMPONENT (required, `string`) ... IoT component (cygnus-ngsi, Orchestrator, Orion, STH, PEPorion, PEPsth, PEPperseo, PEPiotagent, perseo-fe, perseo-core, IoTAgent)
+ TRANSACTION_ID (optional, `string`) ... Transaction Id
+ CORRELATOR_ID (optional, `string`) ... Correlator Id
+ LOG_LEVEL (optional, `string`) ... Log level (INFO, ERROR, WARN, DEBUG, CRITICAL)
+ CUSTOM_TEXT (optional, `string`) ... Custom text
+ Request (application/json)
{
"SERVICE_USER_NAME":"test_admin_service",
"SERVICE_USER_PASSWORD":"passwd",
"SERVICE_USER_TOKEN":"token",
"TRANSACTION_ID":"1552008898-556-00000004824",
"CORRELATOR_ID":"630a1245-6f72-4b33-a93e-f151a5e6b098",
"LOG_LEVEL":"ERROR",
"CUSTOM_TEXT":"core dumped"
}
+ Response 200 (application/json)
+ Body { <splunk_output> }

## Search something relevant into subservice of a Service in Splunk [/v1.0/service/{serviceId}/subservice/{subserviceId}/relevant/{component}]

### search something relevant into subservice of a Service [POST]
+ Parameters
+ serviceId (required, `string`) ... Service Id
+ subserviceId (required, `string`) ... SubService Id
+ COMPONENT (required, `string`) ... IoT component (cygnus-ngsi, Orchestrator, Orion, STH, PEPorion, PEPsth, PEPperseo, PEPiotagent, perseo-fe, perseo-core, IoTAgent)
+ TRANSACTION_ID (optional, `string`) ... Transaction Id
+ CORRELATOR_ID (optional, `string`) ... Correlator Id
+ LOG_LEVEL (optional, `string`) ... Log level (INFO, ERROR, WARN, DEBUG, CRITICAL)
+ CUSTOM_TEXT (optional, `string`) ... Custom text
+ Request (application/json)
{
"SERVICE_USER_NAME":"test_admin_service",
"SERVICE_USER_PASSWORD":"passwd",
"SERVICE_USER_TOKEN":"token",
"TRANSACTION_ID":"1552008898-556-00000004824",
"CORRELATOR_ID":"630a1245-6f72-4b33-a93e-f151a5e6b098",
"LOG_LEVEL":"ERROR",
"CUSTOM_TEXT":"core dumped"
}
+ Response 200 (application/json)
+ Body { <splunk_output> }
26 changes: 26 additions & 0 deletions bin/orchestrator-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ MAILER_TO=smtpuser

MONGODB_URI='localhost:27017'

SPLUNK_HOST=localhost
SPLUNK_PORT=8089
SPLUNK_PROTOCOL=https
SPLUNK_USER=user
SPLUNK_PASSWORD=yourpassword

PEP_PASSWORD=pep
IOTAGENT_PASSWORD=iotagent

Expand Down Expand Up @@ -92,6 +98,9 @@ while [[ $# -gt 0 ]]; do
-mailerhost)
MAILER_HOST=$VALUE
;;
-splunkhost)
SPLUNK_HOST=$VALUE
;;
-keystoneport)
KEYSTONE_PORT=$VALUE
;;
Expand Down Expand Up @@ -119,6 +128,9 @@ while [[ $# -gt 0 ]]; do
-mailerport)
MAILER_PORT=$VALUE
;;
-splunkport)
SPLUNK_PORT=$VALUE
;;
-ldapbasedn)
LDAP_BASEDN=$VALUE
;;
Expand Down Expand Up @@ -146,6 +158,12 @@ while [[ $# -gt 0 ]]; do
-cygnusmultiagent)
CYGNUS_MULTIAGENT=$VALUE
;;
-splunkuser)
SPLUNK_USER=$VALUE
;;
-splunkpasswd)
SPLUNK_PASSWORD=$VALUE
;;
-debuglevel)
DEBUG_LEVEL=$VALUE
;;
Expand Down Expand Up @@ -276,6 +294,14 @@ sed -i ':a;N;$!ba;s/IOTAGENT = {[A-Za-z0-9,=@.\-\/\"\n: ]*}/IOTAGENT = { \
\"password\": \"'$IOTAGENT_PASSWORD'\", \
}/g' /opt/orchestrator/settings/dev.py

sed -i ':a;N;$!ba;s/SPLUNK = {[A-Za-z0-9,=@.\-\/\"\n: ]*}/SPLUNK = { \
\"protocol\": \"'$SPLUNK_PROTOCOL'\", \
\"host\": \"'$SPLUNK_HOST'\", \
\"port\": \"'$SPLUNK_PORT'\", \
\"user\": \"'$SPLUNK_USER'\", \
\"password\": \"'$SPLUNK_PASSWORD'\", \
}/g' /opt/orchestrator/settings/dev.py



if [ "$DEBUG_LEVEL" ]; then
Expand Down
15 changes: 15 additions & 0 deletions src/orchestrator/api/iotconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ def __init__(self):
"Forcing to use default conf values (127.0.0.1:27017)")
self.MONGODB_URI = "mongnodb://127.0.0.1:27017"

try:
self.SPLUNK_PROTOCOL = settings.SPLUNK['protocol']
self.SPLUNK_HOST = settings.SPLUNK['host']
self.SPLUNK_PORT = settings.SPLUNK['port']
self.SPLUNK_USER = settings.SPLUNK['user']
self.SPLUNK_PASSWORD = settings.SPLUNK['password']
except KeyError:
logger.warn("SPLUNK endpoint configuration error. " +
"Forcing to use default conf values (localhost)")
self.SPLUNK_HOST = "localhost"
self.SPLUNK_PORT = "8089"
self.SPLUNK_PROTOCOL = "https"
self.SPLUNK_USER = "user"
self.SPLUNK_PASSWORD = "pass"


# Get Django status error from simple HTTP error code
def getStatusFromCode(self, code):
Expand Down
Loading