diff --git a/pom.xml b/pom.xml index 3c0229222..ebbdae0a1 100644 --- a/pom.xml +++ b/pom.xml @@ -271,6 +271,10 @@ io.quarkus quarkus-flyway + + io.quarkus + quarkus-jfr + io.quarkus quarkus-junit5 diff --git a/schema/openapi.yaml b/schema/openapi.yaml index 7ccd335f9..d77b91598 100644 --- a/schema/openapi.yaml +++ b/schema/openapi.yaml @@ -634,6 +634,7 @@ components: enum: - TARGET - CUSTOM + - PRESET type: string UUID: format: uuid @@ -1164,7 +1165,9 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Template' + items: + $ref: '#/components/schemas/Template' + type: array description: OK "401": description: Not Authorized @@ -1217,6 +1220,59 @@ paths: - SecurityScheme: [] tags: - Event Templates + /api/v4/event_templates/{templateType}: + get: + parameters: + - in: path + name: templateType + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/Template' + type: array + description: OK + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - SecurityScheme: [] + tags: + - Event Templates + /api/v4/event_templates/{templateType}/{templateName}: + get: + parameters: + - in: path + name: templateName + required: true + schema: + type: string + - in: path + name: templateType + required: true + schema: + type: string + responses: + "200": + content: + application/xml: + schema: + type: string + description: OK + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - SecurityScheme: [] + tags: + - Event Templates /api/v4/grafana/{encodedKey}: post: parameters: diff --git a/src/main/docker/Dockerfile.jvm b/src/main/docker/Dockerfile.jvm index 6d68137c4..1973416a0 100644 --- a/src/main/docker/Dockerfile.jvm +++ b/src/main/docker/Dockerfile.jvm @@ -92,6 +92,7 @@ ENTRYPOINT [ "/deployments/app/entrypoint.bash", "/opt/jboss/container/java/run/ # We make distinct layers so if there are application changes the library layers can be re-used COPY --chown=185 src/main/docker/include/cryostat.jfc /usr/lib/jvm/jre/lib/jfr/ +COPY --chown=185 src/main/docker/include/template_presets/* /opt/cryostat.d/presets.d/ COPY --chown=185 src/main/docker/include/genpass.bash /deployments/app/ COPY --chown=185 src/main/docker/include/entrypoint.bash /deployments/app/ COPY --chown=185 src/main/docker/include/truststore-setup.bash /deployments/app/ diff --git a/src/main/docker/include/template_presets/quarkus.jfc b/src/main/docker/include/template_presets/quarkus.jfc new file mode 100644 index 000000000..30e761f50 --- /dev/null +++ b/src/main/docker/include/template_presets/quarkus.jfc @@ -0,0 +1,12 @@ + + + + true + + + true + + + true + + diff --git a/src/main/java/io/cryostat/ConfigProperties.java b/src/main/java/io/cryostat/ConfigProperties.java index e92832b53..af0cf153a 100644 --- a/src/main/java/io/cryostat/ConfigProperties.java +++ b/src/main/java/io/cryostat/ConfigProperties.java @@ -54,7 +54,8 @@ public class ConfigProperties { "storage.transient-archives.enabled"; public static final String STORAGE_TRANSIENT_ARCHIVES_TTL = "storage.transient-archives.ttl"; - public static final String TEMPLATES_DIR = "templates-dir"; + public static final String CUSTOM_TEMPLATES_DIR = "templates-dir"; + public static final String PRESET_TEMPLATES_DIR = "preset-templates-dir"; public static final String SSL_TRUSTSTORE_DIR = "ssl.truststore.dir"; public static final String URI_RANGE = "cryostat.target.uri-range"; diff --git a/src/main/java/io/cryostat/events/EventTemplates.java b/src/main/java/io/cryostat/events/EventTemplates.java index 5beac994b..7a7a95a7b 100644 --- a/src/main/java/io/cryostat/events/EventTemplates.java +++ b/src/main/java/io/cryostat/events/EventTemplates.java @@ -21,6 +21,7 @@ import io.cryostat.core.FlightRecorderException; import io.cryostat.core.templates.MutableTemplateService.InvalidXmlException; +import io.cryostat.core.templates.TemplateService; import io.cryostat.libcryostat.sys.FileSystem; import io.cryostat.libcryostat.templates.InvalidEventTemplateException; import io.cryostat.libcryostat.templates.Template; @@ -35,7 +36,9 @@ import jakarta.ws.rs.NotFoundException; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.UriInfo; import org.apache.commons.lang3.StringUtils; import org.jboss.logging.Logger; @@ -60,6 +63,7 @@ public class EventTemplates { @Inject FileSystem fs; @Inject TargetTemplateService.Factory targetTemplateServiceFactory; @Inject S3TemplateService customTemplateService; + @Inject PresetTemplateService presetTemplateService; @Inject Logger logger; @GET @@ -69,21 +73,47 @@ public List