Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
org.etsi.osl.metrico
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
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
OSL
code
org.etsi.osl.metrico
Commits
4564d6af
Commit
4564d6af
authored
4 months ago
by
George Tziavas
Browse files
Options
Downloads
Patches
Plain Diff
removed previous implementation related files
parent
9a15910b
No related branches found
No related tags found
2 merge requests
!5
MR for Release 2024Q4
,
!1
Creating first version of metrico
Pipeline
#10465
failed
4 months ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/etsi/osl/metrico/MetricoController.java
+0
-78
0 additions, 78 deletions
src/main/java/org/etsi/osl/metrico/MetricoController.java
src/main/java/org/etsi/osl/metrico/model/PeriodicQueryRequest.java
+0
-19
0 additions, 19 deletions
...java/org/etsi/osl/metrico/model/PeriodicQueryRequest.java
with
0 additions
and
97 deletions
src/main/java/org/etsi/osl/metrico/MetricoController.java
deleted
100644 → 0
+
0
−
78
View file @
9a15910b
package
org.etsi.osl.metrico
;
import
org.etsi.osl.metrico.model.Job
;
import
org.etsi.osl.metrico.model.PeriodicQueryRequest
;
import
org.etsi.osl.metrico.prometheus.PrometheusQueries
;
import
org.etsi.osl.tmf.pm628.model.ExecutionStateType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Arrays
;
@RestController
public
class
MetricoController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MetricoController
.
class
);
private
final
PrometheusQueries
prometheusQueries
;
@Autowired
public
MetricoController
(
PrometheusQueries
prometheusQueries
)
{
this
.
prometheusQueries
=
prometheusQueries
;
}
@GetMapping
(
"/live"
)
public
ResponseEntity
<
String
>
livenessCheck
()
{
return
new
ResponseEntity
<>(
"Application is running"
,
HttpStatus
.
OK
);
}
// @GetMapping("/queryPrometheus")
// public ResponseEntity<String> queryPrometheus(
// @RequestParam(defaultValue = "https") String protocol,
// @RequestParam(required = false) String prom_ip,
// @RequestParam(defaultValue = "9000") String prom_port,
// @RequestParam String query
// ) {
// if (prom_ip == null) {
// return new ResponseEntity<>("prom_ip parameter is missing", HttpStatus.BAD_REQUEST);
// }
// String prom_url = protocol + "://" + prom_ip + ":" + prom_port;
// String[] prometheusData = PrometheusQueries.sendQueryToPrometheus(prom_url, query).split("\n");
// return new ResponseEntity<>(Arrays.toString(prometheusData), HttpStatus.OK);
// }
@PostMapping
(
"/startPeriodicQuery"
)
public
ResponseEntity
<
String
>
startPeriodicQuery
(
@RequestBody
PeriodicQueryRequest
request
)
{
logger
.
atDebug
().
setMessage
(
"/startPeriodicQuery endpoint called with request body: "
+
request
).
log
();
logger
.
atInfo
().
setMessage
(
"/startPeriodicQuery endpoint called with query: "
+
request
.
getQuery
()).
log
();
if
(
request
.
getProm_ip
()
==
null
)
{
logger
.
atInfo
().
setMessage
(
"/startPeriodicQuery endpoint called without a prometheus_ip: "
+
request
).
log
();
HttpHeaders
responseHeaders
=
new
HttpHeaders
();
responseHeaders
.
set
(
"Error"
,
"prom_ip parameter is missing"
);
return
new
ResponseEntity
<>(
"prom_ip parameter is missing"
,
responseHeaders
,
HttpStatus
.
BAD_REQUEST
);
}
if
(
request
.
getQuery
()
==
null
)
{
logger
.
atInfo
().
setMessage
(
"/startPeriodicQuery endpoint called without a query: "
+
request
).
log
();
HttpHeaders
responseHeaders
=
new
HttpHeaders
();
responseHeaders
.
set
(
"Error"
,
"query parameter is missing"
);
return
new
ResponseEntity
<>(
"query parameter is missing"
,
responseHeaders
,
HttpStatus
.
BAD_REQUEST
);
}
if
(
request
.
getEndDateTime
()
==
null
){
logger
.
atDebug
().
setMessage
(
"/startPeriodicQuery endpoint called without a stopAfterSeconds. Job will not stop by itself."
).
log
();
}
String
prom_url
=
request
.
getProtocol
()
+
"://"
+
request
.
getProm_ip
()
+
":"
+
request
.
getProm_port
();
Job
newPeriodicQuery
=
prometheusQueries
.
startPeriodicQuery
(
prom_url
,
request
.
getQuery
(),
request
.
getStartDateTime
(),
request
.
getEndDateTime
(),
request
.
getExecutionInterval
());
if
(
newPeriodicQuery
.
getState
()
==
ExecutionStateType
.
FAILED
){
return
new
ResponseEntity
<>(
"Periodic query failed to start due to internal error."
,
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
return
new
ResponseEntity
<>(
"Periodic query started, with ID: "
+
newPeriodicQuery
.
getUuid
(),
HttpStatus
.
OK
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/org/etsi/osl/metrico/model/PeriodicQueryRequest.java
deleted
100644 → 0
+
0
−
19
View file @
9a15910b
package
org.etsi.osl.metrico.model
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.time.OffsetDateTime
;
@Setter
@Getter
public
class
PeriodicQueryRequest
{
private
String
protocol
=
"https"
;
private
String
prom_ip
;
private
String
prom_port
=
"9090"
;
private
String
query
;
private
OffsetDateTime
startDateTime
;
private
OffsetDateTime
endDateTime
;
private
int
executionInterval
=
300
;
private
Job
job
;
}
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