Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
faa6c684
Commit
faa6c684
authored
7 months ago
by
Waleed Akbar
Browse files
Options
Downloads
Patches
Plain Diff
Changes in Analytics Backend.
- Updated function names.
parent
21832189
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!261
(CTTC) New Analytics Component
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/analytics/backend/service/SparkStreaming.py
+4
-4
4 additions, 4 deletions
src/analytics/backend/service/SparkStreaming.py
with
4 additions
and
4 deletions
src/analytics/backend/service/SparkStreaming.py
+
4
−
4
View file @
faa6c684
...
...
@@ -44,7 +44,7 @@ def DefiningRequestSchema():
StructField
(
"
kpi_value
"
,
DoubleType
()
,
True
)
])
def
g
et
_a
ggregations
(
oper_list
):
def
G
et
A
ggregations
(
oper_list
):
# Define the possible aggregation functions
agg_functions
=
{
'
avg
'
:
round
(
avg
(
"
kpi_value
"
),
3
)
.
alias
(
"
avg_value
"
),
...
...
@@ -56,7 +56,7 @@ def get_aggregations(oper_list):
}
return
[
agg_functions
[
op
]
for
op
in
oper_list
if
op
in
agg_functions
]
# Filter and return only the selected aggregations
def
a
pply
_t
hresholds
(
aggregated_df
,
thresholds
):
def
A
pply
T
hresholds
(
aggregated_df
,
thresholds
):
# Apply thresholds (TH-Fail and TH-RAISE) based on the thresholds dictionary on the aggregated DataFrame.
# Loop through each column name and its associated thresholds
...
...
@@ -114,9 +114,9 @@ def SparkStreamer(kpi_list, oper_list, window_size=None, win_slide_duration=None
),
col
(
"
kpi_id
"
)
)
\
.
agg
(
*
g
et
_a
ggregations
(
oper_list
))
.
agg
(
*
G
et
A
ggregations
(
oper_list
))
# Apply thresholds to the aggregated data
thresholded_stream_data
=
a
pply
_t
hresholds
(
windowed_stream_data
,
thresholds
)
thresholded_stream_data
=
A
pply
T
hresholds
(
windowed_stream_data
,
thresholds
)
# --- This will write output on console: FOR TESTING PURPOSES
# Start the Spark streaming query
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment