Commit 5eab53c3 authored by Bashar's avatar Bashar

Updated folder structure 2

parent fd96552b

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (ColabAI)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ColabAI.iml" filepath="$PROJECT_DIR$/.idea/ColabAI.iml" />
</modules>
</component>
</project>
\ No newline at end of file
import numpy as np
import pandas as pd
from imblearn.over_sampling import SMOTE
from imblearn.pipeline import Pipeline
from imblearn.under_sampling import RandomUnderSampler
from sklearn.ensemble import AdaBoostClassifier, BaggingClassifier, GradientBoostingClassifier
from sklearn.metrics import cohen_kappa_score, f1_score, recall_score, confusion_matrix
from sklearn.model_selection import GridSearchCV, StratifiedKFold
from sklearn.tree import DecisionTreeClassifier
def kappa_scorer(estimator, X, y):
y_pred = estimator.predict(X)
return cohen_kappa_score(y, y_pred)
def BestParams(model,param_grid,X,y):
grid_search = GridSearchCV(model, param_grid, scoring=kappa_scorer, cv=10)
grid_search.fit(X, y)
print("Best Parameters: ", grid_search.best_params_)
print("Best Kappa Score: ", grid_search.best_score_)
return grid_search.best_params_
def Metrics(model,X,y):
cv = StratifiedKFold(n_splits=10, shuffle=False, random_state=None)
f1_scores = []
sensitivities = []
g_means = []
kappas = []
# Perform cross-validation
for train_index, test_index in cv.split(X, y):
trains = [True if i in train_index else False for i in range(len(X))]
tests = [True if i in test_index else False for i in range(len(X))]
train_index = trains
test_index = tests
X_train, X_test = X[train_index], X[test_index]
y_train, y_test = y[train_index], y[test_index]
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
# Calculate the metrics for each class
f1_scores.append(f1_score(y_test, y_pred, average=None))
sensitivities.append(recall_score(y_test, y_pred, average=None))
g_means.append(
np.sqrt(recall_score(y_test, y_pred, average=None) * recall_score(y_test, y_pred, average=None)).mean())
kappas.append(cohen_kappa_score(y_test, y_pred))
avg_f1_scores = np.mean(f1_scores, axis=0)
avg_sensitivities = np.mean(sensitivities, axis=0)
avg_g_mean = np.mean(g_means)
avg_kappa = np.mean(kappas)
for i, class_label in enumerate(model.classes_):
print(f"Metrics for class {class_label}:")
print(f"F1-Score: {avg_f1_scores[i]}")
print(f"Sensitivity: {avg_sensitivities[i]}")
print()
print(f"Average G-Mean: {avg_g_mean}")
print(f"Average Kappa: {avg_kappa}")
cm = confusion_matrix(y_test, y_pred)
print(cm)
datasets = ["data_F1.csv","data_F2.csv","data_A1.csv","data_A2.csv"]
for s in datasets:
data = pd.read_csv(s)
X = data.drop('class', axis=1)
X = X.drop('timestamp', axis=1)
y = data['class']
over = SMOTE(sampling_strategy="auto")
under = RandomUnderSampler(sampling_strategy={"NE":round(0.7*len(X))})
# steps = [('u', under),('o', over)]
steps = [('o', over)]
pipeline = Pipeline(steps=steps)
X, y = pipeline.fit_resample(X, y)
print(len(X))
base_classifier = DecisionTreeClassifier()
bagging_classifier = BaggingClassifier(base_classifier)
gradient = GradientBoostingClassifier()
adaboost = AdaBoostClassifier()
n_estimators = [10,50,100,150,200]
learning_rate = 0.1
print("*** Result for file: ", s,"\n")
for i in range(len(n_estimators)):
# print("Bagging Results for a number of estimators ",n_estimators[i])
# # best = BestParams(bagging_classifier,param_grid_bag,X,y)
# bagging_classifier = BaggingClassifier(base_classifier,n_estimators=n_estimators[i])
# Metrics(bagging_classifier,X,y)
# print("********\n")
# print("AdaBoost Results for a number of estimators",n_estimators[i])
# # best = BestParams(adaboost, param_grid_boost,X,y)
# adaboost = AdaBoostClassifier(n_estimators=n_estimators[i],learning_rate=learning_rate)
# Metrics(adaboost, X, y)
print("********\n")
print("GradientBoost Results for a number of estimators", n_estimators[i])
gradient = GradientBoostingClassifier(n_estimators=n_estimators[i],learning_rate=learning_rate)
Metrics(gradient,X,y)
print("********\n")
import numpy as np
import pandas as pd
from imblearn.over_sampling import SMOTE
from imblearn.pipeline import Pipeline
from imblearn.under_sampling import RandomUnderSampler
from sklearn.ensemble import AdaBoostClassifier, BaggingClassifier, GradientBoostingClassifier
from sklearn.metrics import cohen_kappa_score, f1_score, recall_score, confusion_matrix, accuracy_score
from sklearn.model_selection import GridSearchCV, StratifiedKFold, train_test_split
from sklearn.tree import DecisionTreeClassifier
data = pd.read_csv('data_A1.csv')
X = data.drop('class', axis=1)
X = X.drop('timestamp', axis=1)
y = data['class']
X_smote, y_smote = X, y
smote = SMOTE(sampling_strategy='auto')
# X_smote, y_smote = smote.fit_resample(X, y)
X_train, X_test, y_train, y_test = train_test_split(X_smote, y_smote, test_size=0.3, random_state=42)
X_smote, y_smote = smote.fit_resample(X_train, y_train)
X_train, y_train = X_smote,y_smote
# X_test, y_test = X, y
base_classifier = DecisionTreeClassifier()
bagging_classifier = BaggingClassifier(base_classifier,n_estimators=150)
bagging_classifier.fit(X_train,y_train)
y_pred = bagging_classifier.predict(X_test)
########################
f1_scores = []
sensitivities = []
g_means = []
kappas = []
accuracies = []
f1_scores.append(f1_score(y_test, y_pred, average=None))
sensitivities.append(recall_score(y_test, y_pred, average=None))
g_means.append(
np.sqrt(recall_score(y_test, y_pred, average=None) * recall_score(y_test, y_pred, average=None)).mean())
kappas.append(cohen_kappa_score(y_test, y_pred))
accuracies.append(accuracy_score(y_test, y_pred))
print("************\n")
cm = confusion_matrix(y_test, y_pred)
print(cm)
avg_f1_scores = np.mean(f1_scores, axis=0)
avg_sensitivities = np.mean(sensitivities, axis=0)
avg_g_mean = np.mean(g_means)
avg_kappa = np.mean(kappas)
avg_accuracy = np.mean(accuracies)
for i, class_label in enumerate(bagging_classifier.classes_):
print(f"Metrics for class {class_label}:")
print(f"F1-Score: {avg_f1_scores[i]}")
print(f"Sensitivity: {avg_sensitivities[i]}")
print()
print(f"Average G-Mean: {avg_g_mean}")
print(f"Average Kappa: {avg_kappa}")
print(f"Average Accuracy: {avg_accuracy}")
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
1568675580,1568676360,A
1568733120,1568734200,A
\ No newline at end of file
1556827260,1556827680,A
1556829240,1556829960,A
1556831640,1556832780,A
1559518500,1559518860,A
1559520840,1559521620,A
1559523960,1559524980,A
1559680320,1559680680,A
1559683200,1559683920,A
1559686320,1559687520,A
1561758000,1561758180,A
1561761420,1561762140,A
1562025120,1562027460,A
1556643720,1556644020,D
1556644860,1556645640,D
1556655240,1556656260,D
1556662320,1556662680,D
1556660040,1556661300,D
\ No newline at end of file
1568845320,1568846400,D
1568929020,1568930100,D
1569017520,1569018660,D
\ No newline at end of file
1556730540,1556731680,D
1556733840,1556734140,D
1556735460,1556736180,D
1556739660,1556740740,D
1556814900,1556815320,D
1556816760,1556817480,D
1556812380,1556813520,D
1561739220,1561740180,D
1561856160,1561856880,D
1561941060,1561942320,D
1562085120,1562086560,D
1562340840,1562342220,D
\ No newline at end of file
1568391660,1568392560,D
1568415480,1568416320,D
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
timestamp,ICMP_ping,ICMP_loss,ICMP_response_time,Network_Interfaces_Discovery,EtherLike-MIB_Discovery,Interface_{#IFNAME}({#IFALIAS}):_Duplex_status,Interface_GigabitEthernet0/0:_Inbound_packets_discarded,Interface_GigabitEthernet0/1:_Inbound_packets_discarded,Interface_GigabitEthernet0/2:_Inbound_packets_discarded,Interface_GigabitEthernet0/3:_Inbound_packets_discarded,Interface_GigabitEthernet1/0:_Inbound_packets_discarded,Interface_GigabitEthernet1/1:_Inbound_packets_discarded,Interface_Null0:_Inbound_packets_discarded,Interface_{#IFDESCR}:_Inbound_packets_discarded,Interface_GigabitEthernet0/0:_Inbound_packets_with_errors,Interface_GigabitEthernet0/1:_Inbound_packets_with_errors,Interface_GigabitEthernet0/2:_Inbound_packets_with_errors,Interface_GigabitEthernet0/3:_Inbound_packets_with_errors,Interface_GigabitEthernet1/0:_Inbound_packets_with_errors,Interface_GigabitEthernet1/1:_Inbound_packets_with_errors,Interface_Null0:_Inbound_packets_with_errors,Interface_{#IFDESCR}:_Inbound_packets_with_errors,Interface_GigabitEthernet0/0:_Bits_received,Interface_GigabitEthernet0/1:_Bits_received,Interface_GigabitEthernet0/2:_Bits_received,Interface_GigabitEthernet0/3:_Bits_received,Interface_GigabitEthernet1/0:_Bits_received,Interface_GigabitEthernet1/1:_Bits_received,Interface_Null0:_Bits_received,Interface_{#IFDESCR}:_Bits_received,Interface_GigabitEthernet0/0:_Outbound_packets_discarded,Interface_GigabitEthernet0/1:_Outbound_packets_discarded,Interface_GigabitEthernet0/2:_Outbound_packets_discarded,Interface_GigabitEthernet0/3:_Outbound_packets_discarded,Interface_GigabitEthernet1/0:_Outbound_packets_discarded,Interface_GigabitEthernet1/1:_Outbound_packets_discarded,Interface_Null0:_Outbound_packets_discarded,Interface_{#IFDESCR}:_Outbound_packets_discarded,Interface_GigabitEthernet0/0:_Outbound_packets_with_errors,Interface_GigabitEthernet0/1:_Outbound_packets_with_errors,Interface_GigabitEthernet0/2:_Outbound_packets_with_errors,Interface_GigabitEthernet0/3:_Outbound_packets_with_errors,Interface_GigabitEthernet1/0:_Outbound_packets_with_errors,Interface_GigabitEthernet1/1:_Outbound_packets_with_errors,Interface_Null0:_Outbound_packets_with_errors,Interface_{#IFDESCR}:_Outbound_packets_with_errors,Interface_GigabitEthernet0/0:_Bits_sent,Interface_GigabitEthernet0/1:_Bits_sent,Interface_GigabitEthernet0/2:_Bits_sent,Interface_GigabitEthernet0/3:_Bits_sent,Interface_GigabitEthernet1/0:_Bits_sent,Interface_GigabitEthernet1/1:_Bits_sent,Interface_Null0:_Bits_sent,Interface_{#IFDESCR}:_Bits_sent,Interface_GigabitEthernet0/0:_Speed,Interface_GigabitEthernet0/1:_Speed,Interface_GigabitEthernet0/2:_Speed,Interface_GigabitEthernet0/3:_Speed,Interface_GigabitEthernet1/0:_Speed,Interface_GigabitEthernet1/1:_Speed,Interface_Null0:_Speed,Interface_{#IFDESCR}:_Speed,Interface_GigabitEthernet0/0:_Operational_status,Interface_GigabitEthernet0/1:_Operational_status,Interface_GigabitEthernet0/2:_Operational_status,Interface_GigabitEthernet0/3:_Operational_status,Interface_GigabitEthernet1/0:_Operational_status,Interface_GigabitEthernet1/1:_Operational_status,Interface_Null0:_Operational_status,Interface_{#IFDESCR}:_Operational_status,Interface_GigabitEthernet0/0:_Interface_type,Interface_GigabitEthernet0/1:_Interface_type,Interface_GigabitEthernet0/2:_Interface_type,Interface_GigabitEthernet0/3:_Interface_type,Interface_GigabitEthernet1/0:_Interface_type,Interface_GigabitEthernet1/1:_Interface_type,Interface_Null0:_Interface_type,Interface_{#IFDESCR}:_Interface_type,SNMP_traps_(fallback),Device_contact_details,Device_description,Device_location,Device_name,System_object_ID,Device_uptime,SNMP_availability
1568144885,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,152,784,72,56784,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,18432,38568,1720,296,296,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145065,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,120,1376,72,680,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,400,456,2120,288,288,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145245,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,152,10912,72,2696,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,1072,1560,12104,280,288,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145425,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,152,18040,72,113536,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,176,59664,54208,20192,296,280,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145605,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,144,16568,72,137088,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,184,37736,90600,17984,296,288,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145785,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,160,7768,72,120576,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,200,57784,71664,9240,304,312,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145965,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,144,8368,80,69544,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,208,9560,58992,9440,296,296,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568146145,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,168,9304,80,125240,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,208,22040,104656,10280,312,304,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
timestamp,ICMP_ping,ICMP_loss,ICMP_response_time,Network_Interfaces_Discovery,EtherLike-MIB_Discovery,Interface_{#IFNAME}({#IFALIAS}):_Duplex_status,Interface_GigabitEthernet0/0:_Inbound_packets_discarded,Interface_GigabitEthernet0/1:_Inbound_packets_discarded,Interface_GigabitEthernet0/2:_Inbound_packets_discarded,Interface_GigabitEthernet0/3:_Inbound_packets_discarded,Interface_GigabitEthernet1/0:_Inbound_packets_discarded,Interface_GigabitEthernet1/1:_Inbound_packets_discarded,Interface_Null0:_Inbound_packets_discarded,Interface_{#IFDESCR}:_Inbound_packets_discarded,Interface_GigabitEthernet0/0:_Inbound_packets_with_errors,Interface_GigabitEthernet0/1:_Inbound_packets_with_errors,Interface_GigabitEthernet0/2:_Inbound_packets_with_errors,Interface_GigabitEthernet0/3:_Inbound_packets_with_errors,Interface_GigabitEthernet1/0:_Inbound_packets_with_errors,Interface_GigabitEthernet1/1:_Inbound_packets_with_errors,Interface_Null0:_Inbound_packets_with_errors,Interface_{#IFDESCR}:_Inbound_packets_with_errors,Interface_GigabitEthernet0/0:_Bits_received,Interface_GigabitEthernet0/1:_Bits_received,Interface_GigabitEthernet0/2:_Bits_received,Interface_GigabitEthernet0/3:_Bits_received,Interface_GigabitEthernet1/0:_Bits_received,Interface_GigabitEthernet1/1:_Bits_received,Interface_Null0:_Bits_received,Interface_{#IFDESCR}:_Bits_received,Interface_GigabitEthernet0/0:_Outbound_packets_discarded,Interface_GigabitEthernet0/1:_Outbound_packets_discarded,Interface_GigabitEthernet0/2:_Outbound_packets_discarded,Interface_GigabitEthernet0/3:_Outbound_packets_discarded,Interface_GigabitEthernet1/0:_Outbound_packets_discarded,Interface_GigabitEthernet1/1:_Outbound_packets_discarded,Interface_Null0:_Outbound_packets_discarded,Interface_{#IFDESCR}:_Outbound_packets_discarded,Interface_GigabitEthernet0/0:_Outbound_packets_with_errors,Interface_GigabitEthernet0/1:_Outbound_packets_with_errors,Interface_GigabitEthernet0/2:_Outbound_packets_with_errors,Interface_GigabitEthernet0/3:_Outbound_packets_with_errors,Interface_GigabitEthernet1/0:_Outbound_packets_with_errors,Interface_GigabitEthernet1/1:_Outbound_packets_with_errors,Interface_Null0:_Outbound_packets_with_errors,Interface_{#IFDESCR}:_Outbound_packets_with_errors,Interface_GigabitEthernet0/0:_Bits_sent,Interface_GigabitEthernet0/1:_Bits_sent,Interface_GigabitEthernet0/2:_Bits_sent,Interface_GigabitEthernet0/3:_Bits_sent,Interface_GigabitEthernet1/0:_Bits_sent,Interface_GigabitEthernet1/1:_Bits_sent,Interface_Null0:_Bits_sent,Interface_{#IFDESCR}:_Bits_sent,Interface_GigabitEthernet0/0:_Speed,Interface_GigabitEthernet0/1:_Speed,Interface_GigabitEthernet0/2:_Speed,Interface_GigabitEthernet0/3:_Speed,Interface_GigabitEthernet1/0:_Speed,Interface_GigabitEthernet1/1:_Speed,Interface_Null0:_Speed,Interface_{#IFDESCR}:_Speed,Interface_GigabitEthernet0/0:_Operational_status,Interface_GigabitEthernet0/1:_Operational_status,Interface_GigabitEthernet0/2:_Operational_status,Interface_GigabitEthernet0/3:_Operational_status,Interface_GigabitEthernet1/0:_Operational_status,Interface_GigabitEthernet1/1:_Operational_status,Interface_Null0:_Operational_status,Interface_{#IFDESCR}:_Operational_status,Interface_GigabitEthernet0/0:_Interface_type,Interface_GigabitEthernet0/1:_Interface_type,Interface_GigabitEthernet0/2:_Interface_type,Interface_GigabitEthernet0/3:_Interface_type,Interface_GigabitEthernet1/0:_Interface_type,Interface_GigabitEthernet1/1:_Interface_type,Interface_Null0:_Interface_type,Interface_{#IFDESCR}:_Interface_type,SNMP_traps_(fallback),Device_contact_details,Device_description,Device_location,Device_name,System_object_ID,Device_uptime,SNMP_availability
1568144887,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,152,14848,72,24792,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,15608,9400,18344,272,272,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145067,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,152,13248,72,199496,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,160,51840,150184,15528,288,288,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145248,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,152,4208,80,94008,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,38768,49080,6928,280,288,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145427,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,136,-1,72,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,200,114248,82808,20832,304,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145428,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,17744,-1,192976,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,304,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145607,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,144,15560,72,159744,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,61984,95568,17512,288,296,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145787,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,152,19096,72,146336,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,200,10304,138280,21656,304,304,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568145967,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,160,16200,80,154672,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,192,16288,138576,20760,272,272,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
1568146147,,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,168,21680,88,200120,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,200,48008,150224,23592,304,304,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
\ No newline at end of file
CREATE DATABASE IF NOT EXISTS USER_APP;
USE USER_APP;
CREATE TABLE users(
id int(7) NOT NULL,
username VARCHAR(255) NOT NULL,
fname VARCHAR(255) NOT NULL,
lname VARCHAR(255) NOT NULL,
gender VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
country VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
workingDate DATE DEFAULT NULL,
role VARCHAR(255) NOT NULL,
PRIMARY KEY(userID)
);
ALTER TABLE users ADD CONSTRAINT unique_username UNIQUE (username);
ALTER TABLE users ADD CONSTRAINT unique_username UNIQUE (email);
-- password: reem
INSERT INTO users (id,username,fname,lname, gender, country, email, workingDate, password, role)
VALUES (1,'reem.hasan','John', 'Doe', 'female', 'USA', 'johndoe@example.com', '2023-07-24',
'$2a$10$rC.uZ0ivWwiFJ7PHp8A8XOEFz7Al82SjHsvX27W7PcADX2GHdyu6q', 'admin');
-- password: reem
INSERT INTO users (id,username,fname,lname, gender, country, email, workingDate, password, role)
VALUES (2,'bashar.hussain','John', 'Doe', 'male', 'USA', 'bashar@example.com', '2023-07-24',
'$2a$10$4xbRR/mP2xrbSjN1tK8t/OBZLeTzLplQtG3VvB8mm4T8yA.Fti/AS', 'user');
version: '3'
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.0.1
container_name: zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
broker:
image: confluentinc/cp-kafka:7.0.1
container_name: broker
ports:
- "9092:9092"
depends_on:
- zookeeper
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://172.29.3.220:9092,PLAINTEXT_INTERNAL://broker:29092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
version: '3'
services:
db:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'password'
ports:
- "3306:3306"
volumes:
- ./data.sql:/docker-entrypoint-initdb.d/data.sql
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="ee566820-41c3-4b00-b503-2c67f6bff446" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="useMavenConfig" value="true" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectId" id="2ToSrVjBo2tCVkShhA3ZMGGwlxw" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="event-correlation-service" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="event-correlation-service" options="-parameters" />
</option>
</component>
</project>
\ No newline at end of file
# Read Me First
The following was discovered as part of building this project:
* The original package name 'com.example.event-correlation-service' is invalid and this project uses 'com.example.eventcorrelationservice' instead.
# Getting Started
### Reference Documentation
For further reference, please consider the following sections:
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.1.2/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.1.2/maven-plugin/reference/html/#build-image)
server.port=7373
spring.application.name=FEEDBACK-SERVICE
eureka.client.serviceUrl.defaultZone=http://192.168.27.227:8761/eureka
#eureka.instance.hostname=192.168.24.47
\ No newline at end of file
{
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"set_priority": {
"priority": 100
},
"rollover": {
"max_primary_shard_size": "50gb",
"max_age": "60m"
}
}
},
"warm": {
"min_age": "60m",
"actions": {
"set_priority": {
"priority": 50
}
}
},
"cold": {
"min_age": "60m",
"actions": {
"set_priority": {
"priority": 0
}
}
}
}
}
\ No newline at end of file
{
"settings": {
"index.lifecycle.name": "knowledge-base-policy",
"index.number_of_shards": 1,
"index.number_of_replicas": 0
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="86fae3e4-0459-41fd-9a67-3882ba2fba07" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="GitSEFilterConfiguration">
<file-type-list>
<filtered-out-file-type name="LOCAL_BRANCH" />
<filtered-out-file-type name="REMOTE_BRANCH" />
<filtered-out-file-type name="TAG" />
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
</file-type-list>
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2T7pr1RyWmnylkcTQkZoUYymmpo" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\HP\PycharmProjects\model-service" />
</key>
</component>
<component name="RunManager" selected="Python.main">
<configuration name="eureka" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="model-service" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/eureka.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="model-service" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.eureka" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="86fae3e4-0459-41fd-9a67-3882ba2fba07" name="Changes" comment="" />
<created>1690404170065</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1690404170065</updated>
</task>
<servers />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="stream-service" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="stream-service" options="-parameters" />
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
# Getting Started
### Reference Documentation
For further reference, please consider the following sections:
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.1.1/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.1.1/maven-plugin/reference/html/#build-image)
This diff is collapsed.
server.port = 7777
spring.kafka.bootstrap-servers=http://172.29.3.220:9092
spring.kafka.template.default-topic=Stream-Instance
spring.kafka.consumer.group-id= Stream-Instance-Id
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.cloud.circuitbreaker.resilience4j.enabled=true
management.health.circuitbreakers.enabled=true
management.health.elasticsearch.enabled=false
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
#Resilinece4j Properties
resilience4j.circuitbreaker.instances.model-service.registerHealthIndicator=true
resilience4j.circuitbreaker.instances.model-service.event-consumer-buffer-size=10
resilience4j.circuitbreaker.instances.model-service.slidingWindowType=COUNT_BASED
resilience4j.circuitbreaker.instances.model-service.slidingWindowSize=5
resilience4j.circuitbreaker.instances.model-service.failureRateThreshold=30
resilience4j.circuitbreaker.instances.model-service.waitDurationInOpenState=5s
resilience4j.circuitbreaker.instances.model-service.permittedNumberOfCallsInHalfOpenState=3
resilience4j.circuitbreaker.instances.model-service.automaticTransitionFromOpenToHalfOpenEnabled=true
##Resilience4J Timeout Properties
#resilience4j.timelimiter.instances.model-service.timeout-duration=3s
#
##Resilience4J Retry Properties
#resilience4j.retry.instances.model-service.max-attempts=3
#resilience4j.retry.instances.model-service.wait-duration=5s
spring.application.name=MODEL-STREAM-SERVICE
eureka.client.serviceUrl.defaultZone=http://192.168.27.227:8761/eureka
eureka.instance.hostname=192.168.24.47
\ No newline at end of file
{
"index_patterns": ["model-data-stream*"],
"data_stream": { },
"composed_of": [ "model-setting", "model-mapping"],
"priority": 670,
"_meta": {
"description": "Template for my time series data",
"my-custom-meta-field": "More arbitrary metadata"
}
}
\ No newline at end of file
{
"mappings": {
"properties": {
"Device_uptime": {
"type": "wildcard"
},
"EX_Bits_received": {
"type": "wildcard"
},
"EX_Bits_sent": {
"type": "wildcard"
},
"EX_Inbound_packets_discarded": {
"type": "wildcard"
},
"EX_Inbound_packets_with_errors": {
"type": "wildcard"
},
"EX_Interface_type": {
"type": "wildcard"
},
"EX_Operational_status": {
"type": "wildcard"
},
"EX_Outbound_packets_discarded": {
"type": "wildcard"
},
"EX_Outbound_packets_with_errors": {
"type": "wildcard"
},
"EX_Speed": {
"type": "wildcard"
},
"ICMP_loss": {
"type": "wildcard"
},
"ICMP_ping": {
"type": "wildcard"
},
"ICMP_response_time": {
"type": "wildcard"
},
"IN_Bits_received": {
"type": "wildcard"
},
"IN_Bits_sent": {
"type": "wildcard"
},
"IN_Inbound_packets_discarded": {
"type": "wildcard"
},
"IN_Inbound_packets_with_errors": {
"type": "wildcard"
},
"IN_Interface_type": {
"type": "wildcard"
},
"IN_Operational_status": {
"type": "wildcard"
},
"IN_Outbound_packets_discarded": {
"type": "wildcard"
},
"IN_Outbound_packets_with_errors": {
"type": "wildcard"
},
"IN_Speed": {
"type": "wildcard"
},
"P_Bits_received": {
"type": "wildcard"
},
"P_Bits_sent": {
"type": "wildcard"
},
"P_Inbound_packets_discarded": {
"type": "wildcard"
},
"P_Inbound_packets_with_errors": {
"type": "wildcard"
},
"P_Interface_type": {
"type": "wildcard"
},
"P_Operational_status": {
"type": "wildcard"
},
"P_Outbound_packets_discarded": {
"type": "wildcard"
},
"P_Outbound_packets_with_errors": {
"type": "wildcard"
},
"P_Speed": {
"type": "wildcard"
},
"SNMP_availability": {
"type": "wildcard"
},
"class": {
"type": "wildcard"
},
"range": {
"type": "wildcard"
},
"timestamp": {
"type": "date",
"format": "date_optional_time||epoch_second"
},
"@timestamp": {
"type": "date",
"format": "date_optional_time||epoch_second"
}
}
}
}
\ No newline at end of file
{
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"set_priority": {
"priority": 100
},
"rollover": {
"max_primary_shard_size": "50gb",
"max_age": "60m"
}
}
},
"warm": {
"min_age": "60m",
"actions": {
"set_priority": {
"priority": 50
}
}
},
"cold": {
"min_age": "60m",
"actions": {
"set_priority": {
"priority": 0
}
}
}
}
}
\ No newline at end of file
{
"settings": {
"index.lifecycle.name": "model-policy",
"index.number_of_shards": 1,
"index.number_of_replicas": 0
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment