Skip to content

Commit

Permalink
Add monitoring (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
olevitt authored May 25, 2020
1 parent 0a93f74 commit f1ddc55
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ A valid `JSON` is expected with a list of `region` :
"publish-domain": "fakedomain.marathon.example.com",
"namespace-prefix": "users",
"marathon-dns-suffix": "marathon.containerip.dcos.thisdcos.directory",
"serviceMonitoringURLPattern": "https://graphana.example.com/$appIdSlug",
"cloudshell": {
"catalogId": "internal",
"packageName": "shelly"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ public boolean validateContract(Region region, Group group, App app, User user,
}
}
app.addLabel("ONYXIA_LOGO", (String) ((Map<String, Object>) pkg.getResource().get("images")).get("icon-small"));

if (region.getServiceMonitoringURLPattern() != null) {
String slugId = app.getId();
if (slugId.startsWith("/")) {
slugId = slugId.substring(1);
}
slugId = slugId.replaceAll("/","_");
String monitoringUrl = region.getServiceMonitoringURLPattern().replaceAll("\\$appIdSlug",slugId);
app.addLabel("ONYXIA_MONITORING", monitoringUrl);
}

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ private fr.insee.onyxia.model.service.Service mapAppToService(App app) {
service.getEvents().add(event);
}

if (app.getLabels().containsKey("ONYXIA_MONITORING")) {
fr.insee.onyxia.model.service.Service.Monitoring monitoring = new fr.insee.onyxia.model.service.Service.Monitoring();
monitoring.setUrl(app.getLabels().get("ONYXIA_MONITORING"));
service.setMonitoring(monitoring);
}

return service;
}

Expand Down
1 change: 1 addition & 0 deletions onyxia-api/src/main/resources/regions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "KUBERNETES",
"namespace-prefix": "user-",
"publish-domain": "fakedomain.kub.example.com",
"serviceMonitoringURLPattern": "https://graphana.kub.example.com/$appIdSlug",
"cloudshell": {
"catalogId": "inseefrlab-helm-charts-datascience",
"packageName": "cloudshell"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Region {
Auth auth;
@JsonProperty("cloudshell")
CloudshellConfiguration cloudshellConfiguration;
@JsonProperty("serviceMonitoringURLPattern")
String serviceMonitoringURLPattern;

public String getRegionId() {
return regionId;
Expand Down Expand Up @@ -83,6 +85,14 @@ public void setCloudshellConfiguration(CloudshellConfiguration cloudshellConfigu
this.cloudshellConfiguration = cloudshellConfiguration;
}

public void setServiceMonitoringURLPattern(String serviceMonitoringURLPattern) {
this.serviceMonitoringURLPattern = serviceMonitoringURLPattern;
}

public String getServiceMonitoringURLPattern() {
return serviceMonitoringURLPattern;
}

public static class CloudshellConfiguration {

private String catalogId, packageName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Service {
private List<Task> tasks = new ArrayList<>();
private List<Event> events = new ArrayList<>();
private String subtitle;
private Monitoring monitoring;

private long startedAt;

Expand Down Expand Up @@ -153,11 +154,31 @@ public void setInternalUrls(List<String> internalUrls) {
this.internalUrls = internalUrls;
}

public Monitoring getMonitoring() {
return monitoring;
}

public void setMonitoring(Monitoring monitoring) {
this.monitoring = monitoring;
}

public static enum ServiceStatus {
DEPLOYING, RUNNING, STOPPED;
}

public static enum ServiceType {
KUBERNETES,MARATHON
}

public static class Monitoring {
private String url;

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}
}
}

0 comments on commit f1ddc55

Please sign in to comment.