Skip to content

Commit

Permalink
Merge branch 'main' into feature/2696-Document-level-recommendations
Browse files Browse the repository at this point in the history
* main:
  No issue. Added another example for the MTAS search
  #4388 - Mention health checking endpoint in admin guide
  #4386 - User "null" sometimes shows up in recent activity
  #916 - Changing URL of remote KB requires server restart
  • Loading branch information
reckart committed Dec 19, 2023
2 parents 3a494d6 + 5022e48 commit 6d7532f
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ adding/removing/changing segmentation annotations (i.e. sentences or tokens).

This section describes the global settings related to the support for editable segmentation annotations (i.e. sentences or tokens).

.Knowledge base settings overview
.Segmentation settings overview
[cols="4*", options="header"]
|===
| Setting
Expand All @@ -33,8 +33,8 @@ This section describes the global settings related to the support for editable s
| Example


| ui.sentence-layer-editable=true
| `ui.sentence-layer-editable`
| Enable/disable editing sentences
| false
| true
| `false`
| `true`
|===
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,50 @@
// See the License for the specific language governing permissions and
// limitations under the License.

[[sect_monitoring]]
= Monitoring

== Available metrics
[[sect_health_check]]
== Health check

{product-name} offers a health-checking endpoint at `.../actuator/health`. It provides a JSON response indicating
whether the application is up and running.

[source,json]
----
{
"status":"UP",
"components":{
"db":{
"status":"UP",
"details":{
"database":"MariaDB",
"validationQuery":"isValid()"
}
},
"diskSpace":{
"status":"UP",
"details":{
"total": ...,
"free": ...,
"threshold": ...,
"exists":true
}
},
"ping":{
"status":"UP"
}
}
}
----


== Metrics

====
NOTE: to make the metrics available `spring.jmx.enabled=true` and `monitoring.metrics.enabled=true` must be set in
the `settings.properties` file (see <<sect_home_folder>> on this file)..
====

We expose some metrics of the running {product-name} instance via JMX. These are currently

Expand All @@ -25,10 +66,6 @@ We expose some metrics of the running {product-name} instance via JMX. These are
* the number of enabled recommenders
* the number of annotation documents i.e. documents being annotated per user

To make the metrics available `spring.jmx.enabled=true`
and `monitoring.metrics.enabled=true`
must be set in the `settings.properties` file
(see <<sect_home_folder>> on this file).

== Setting up metrics exporter

Expand All @@ -40,7 +77,8 @@ file next to the {product-name} .jar file. An example `config.yml` file that exp
INCEpTION but not webanno brat metrics (metrics associated with brat rendering) and conforms JMX metric
names to https://prometheus.io/docs/practices/naming/[Prometheus Naming conventions] is:

....
[source,yaml]
----
ssl: false
whitelistObjectNames: ["de.tudarmstadt.ukp.inception.recommendation.metrics:*",
"de.tudarmstadt.ukp.clarin.webanno.api.dao.metrics:*", "de.tudarmstadt.ukp.clarin.webanno.security.metrics:*"]
Expand All @@ -61,16 +99,17 @@ rules:
help: "Inception metric $4"
type: GAUGE
attrNameSnakeCase: true
....
----

The following line will run the JMX exporter for the JVM that runs the inception.jar.
The exporter will expose the metrics on the http-endpoint _localhost:9404_.
Make sure to use a port, 9404 in this case, that is not open to the public
(only to the local network that your Prometheus instance runs in).

....
java -javaagent:./jmx_prometheus_javaagent-0.13.0.jar=9404:config.yaml -jar inception.jar
....
[source,sh]
----
$ java -javaagent:./jmx_prometheus_javaagent-0.13.0.jar=9404:config.yaml -jar inception.jar
----

The JMX exporter will also automatically expose JVM metrics in the `java.lang` namespace
which can be used to e.g. monitor memory usage:
Expand Down Expand Up @@ -117,6 +156,7 @@ By default, only unhandled exceptions are sent to Sentry. This behavior can be t

More option that can be overwritten are listed in https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/[the official Sentry SDK ducumentation].


== Scheduling
The default schedule for pulling of Prometheus is 10s, however it is necessary to make this a longer
interval to avoid overwhelming your {product-name} instance with requests for metrics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -80,6 +81,7 @@
import org.eclipse.rdf4j.repository.sail.SailRepository;
import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection;
import org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig;
import org.eclipse.rdf4j.repository.sparql.SPARQLConnection;
import org.eclipse.rdf4j.repository.sparql.SPARQLRepository;
import org.eclipse.rdf4j.repository.sparql.config.SPARQLRepositoryConfig;
import org.eclipse.rdf4j.rio.RDFFormat;
Expand Down Expand Up @@ -323,7 +325,7 @@ public void registerKnowledgeBase(KnowledgeBase aKB, RepositoryImplConfig aCfg)

// We want to have a separate Lucene index for every local repo, so we need to hack the
// index dir in here because this is the place where we finally know the repo ID.
syncIndexParameters(aKB, aCfg);
setLuceneIndexConfigurtionParameters(aKB, aCfg);

repoManager.addRepositoryConfig(new RepositoryConfig(repositoryId, aCfg));
entityManager.persist(aKB);
Expand Down Expand Up @@ -407,12 +409,17 @@ public void updateKnowledgeBase(KnowledgeBase kb)

@Transactional
@Override
public void updateKnowledgeBase(KnowledgeBase kb, RepositoryImplConfig cfg)
public void updateKnowledgeBase(KnowledgeBase aKB, RepositoryImplConfig cfg)
throws RepositoryException, RepositoryConfigException
{
assertRegistration(kb);
repoManager.addRepositoryConfig(new RepositoryConfig(kb.getRepositoryId(), cfg));
updateKnowledgeBase(kb);
assertRegistration(aKB);
repoManager.addRepositoryConfig(new RepositoryConfig(aKB.getRepositoryId(), cfg));

// Drop cached results from the KB being updated
queryCache.asMap().keySet()
.removeIf(key -> Objects.equals(key.kb.getRepositoryId(), aKB.getRepositoryId()));

updateKnowledgeBase(aKB);
}

@Transactional
Expand Down Expand Up @@ -517,7 +524,9 @@ public RepositoryConnection getConnection(KnowledgeBase kb)
{
skipCertificateChecks(kb.isSkipSslValidation());

syncIndexParameters(kb, getDelegate());
syncLuceneQueryLiveParameters(kb, getDelegate());

syncSparqlUrlLiveParameters(kb, getDelegate());
}

@Override
Expand Down Expand Up @@ -1393,11 +1402,11 @@ void reconfigureLocalKnowledgeBase(KnowledgeBase aKB)
*/

var config = getNativeConfig();
syncIndexParameters(aKB, config);
setLuceneIndexConfigurtionParameters(aKB, config);
repoManager.addRepositoryConfig(new RepositoryConfig(aKB.getRepositoryId(), config));
}

private void syncIndexParameters(KnowledgeBase aKB, RepositoryImplConfig aCfg)
private void setLuceneIndexConfigurtionParameters(KnowledgeBase aKB, RepositoryImplConfig aCfg)
{
assertRegistration(aKB);

Expand All @@ -1421,7 +1430,7 @@ private void syncIndexParameters(KnowledgeBase aKB, RepositoryImplConfig aCfg)
}
}

private void syncIndexParameters(KnowledgeBase kb, RepositoryConnection aConn)
private void syncLuceneQueryLiveParameters(KnowledgeBase kb, RepositoryConnection aConn)
{
try {
if (aConn instanceof SailRepositoryConnection sailRepo) {
Expand All @@ -1440,6 +1449,35 @@ private void syncIndexParameters(KnowledgeBase kb, RepositoryConnection aConn)
}
}

private void syncSparqlUrlLiveParameters(KnowledgeBase kb,
RepositoryConnection aRepositoryConnection)
{
try {
if (aRepositoryConnection instanceof SPARQLConnection sparqlConnection) {
var sparqlRepoConfig = (SPARQLRepositoryConfig) getKnowledgeBaseConfig(kb);
var repository = sparqlConnection.getRepository();

var queryEndpointUrl = sparqlRepoConfig.getQueryEndpointUrl();
var updateEndpointUrl = sparqlRepoConfig.getUpdateEndpointUrl();
if (updateEndpointUrl == null) {
updateEndpointUrl = queryEndpointUrl;
}

writeField(repository, "queryEndpointUrl", queryEndpointUrl, true);
writeField(repository, "updateEndpointUrl", updateEndpointUrl, true);

var session = readField(sparqlConnection, "client", true);
writeField(session, "queryURL", queryEndpointUrl, true);
writeField(session, "updateURL", updateEndpointUrl, true);
}
}
catch (Exception e) {
throw new RuntimeException("Unable to sync URL into live SPARQL connection - "
+ "maybe the SPARQLConnection or SPARQLProtocolSession implementation has changed.",
e);
}
}

@Override
public void rebuildFullTextIndex(KnowledgeBase aKB) throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ feature has the given value.
Notice that the multi-token query syntax can also be used to retrieve single token annotations (e.g.
POS or lemma annotations).

=== Basic Annotation queries

=== Text queriess

.Single token: all occurrences of the token *Galicia*
----
Expand All @@ -59,6 +60,9 @@ The capital of Galicia
----
"The" "capital" "of" "Galicia"
----


=== Span layer queries

.Lemma: all occurrences of the lemma *sign*
----
Expand Down Expand Up @@ -168,6 +172,12 @@ The capital of Galicia
(<Named_entity.value="OTH"/> | <Named_entity.value="LOC"/>) intersecting <SemArg/>
----

.Search for sentences containing a PER named entity
----
<s> []{0,50} <Named_entity.value="PER"/> []{0,50} </s> within <s/>
----


=== Relation layer queries

{product-name} allows queries over relation annotations as well. When relations are indexed, they
Expand Down

0 comments on commit 6d7532f

Please sign in to comment.