From be2eae9d228193320cd8a4fa696505c6efb6772c Mon Sep 17 00:00:00 2001 From: squahtx Date: Tue, 7 Dec 2021 16:19:22 +0000 Subject: deploy: 26b5d2320f62b5eb6262c7614fbdfc364a4dfc02 --- .../admin_api/background_updates.html | 2 +- .../usage/administration/admin_api/federation.html | 348 ++++++++++++++++++ latest/usage/administration/admin_api/index.html | 2 +- .../admin_api/registration_tokens.html | 2 +- latest/usage/administration/admin_faq.html | 317 +++++++++++++++++ .../administration/database_maintenance_tools.html | 267 ++++++++++++++ latest/usage/administration/index.html | 2 +- latest/usage/administration/request_log.html | 10 +- latest/usage/administration/state_groups.html | 268 ++++++++++++++ ...derstanding_synapse_through_grafana_graphs.html | 305 ++++++++++++++++ .../administration/useful_sql_for_admins.html | 389 +++++++++++++++++++++ .../configuration/homeserver_sample_config.html | 40 ++- latest/usage/configuration/index.html | 2 +- .../usage/configuration/logging_sample_config.html | 2 +- .../configuration/user_authentication/index.html | 2 +- .../user_authentication/single_sign_on/cas.html | 2 +- .../user_authentication/single_sign_on/index.html | 2 +- .../user_authentication/single_sign_on/saml.html | 2 +- 18 files changed, 1948 insertions(+), 16 deletions(-) create mode 100644 latest/usage/administration/admin_api/federation.html create mode 100644 latest/usage/administration/admin_faq.html create mode 100644 latest/usage/administration/database_maintenance_tools.html create mode 100644 latest/usage/administration/state_groups.html create mode 100644 latest/usage/administration/understanding_synapse_through_grafana_graphs.html create mode 100644 latest/usage/administration/useful_sql_for_admins.html (limited to 'latest/usage') diff --git a/latest/usage/administration/admin_api/background_updates.html b/latest/usage/administration/admin_api/background_updates.html index be08324c24..688343ffca 100644 --- a/latest/usage/administration/admin_api/background_updates.html +++ b/latest/usage/administration/admin_api/background_updates.html @@ -99,7 +99,7 @@ diff --git a/latest/usage/administration/admin_api/federation.html b/latest/usage/administration/admin_api/federation.html new file mode 100644 index 0000000000..fca212a992 --- /dev/null +++ b/latest/usage/administration/admin_api/federation.html @@ -0,0 +1,348 @@ + + + + + + Federation - Synapse + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + +
+
+ +
+ +
+ +

Federation API

+

This API allows a server administrator to manage Synapse's federation with other homeservers.

+

Note: This API is new, experimental and "subject to change".

+

List of destinations

+

This API gets the current destination retry timing info for all remote servers.

+

The list contains all the servers with which the server federates, +regardless of whether an error occurred or not. +If an error occurs, it may take up to 20 minutes for the error to be displayed here, +as a complete retry must have failed.

+

The API is:

+

A standard request with no filtering:

+
GET /_synapse/admin/v1/federation/destinations
+
+

A response body like the following is returned:

+
{
+   "destinations":[
+      {
+         "destination": "matrix.org",
+         "retry_last_ts": 1557332397936,
+         "retry_interval": 3000000,
+         "failure_ts": 1557329397936,
+         "last_successful_stream_ordering": null
+      }
+   ],
+   "total": 1
+}
+
+

To paginate, check for next_token and if present, call the endpoint again +with from set to the value of next_token. This will return a new page.

+

If the endpoint does not return a next_token then there are no more destinations +to paginate through.

+

Parameters

+

The following query parameters are available:

+
    +
  • from - Offset in the returned list. Defaults to 0.
  • +
  • limit - Maximum amount of destinations to return. Defaults to 100.
  • +
  • order_by - The method in which to sort the returned list of destinations. +Valid values are: +
      +
    • destination - Destinations are ordered alphabetically by remote server name. +This is the default.
    • +
    • retry_last_ts - Destinations are ordered by time of last retry attempt in ms.
    • +
    • retry_interval - Destinations are ordered by how long until next retry in ms.
    • +
    • failure_ts - Destinations are ordered by when the server started failing in ms.
    • +
    • last_successful_stream_ordering - Destinations are ordered by the stream ordering +of the most recent successfully-sent PDU.
    • +
    +
  • +
  • dir - Direction of room order. Either f for forwards or b for backwards. Setting +this value to b will reverse the above sort order. Defaults to f.
  • +
+

Caution: The database only has an index on the column destination. +This means that if a different sort order is used, +this can cause a large load on the database, especially for large environments.

+

Response

+

The following fields are returned in the JSON response body:

+
    +
  • destinations - An array of objects, each containing information about a destination. +Destination objects contain the following fields: +
      +
    • destination - string - Name of the remote server to federate.
    • +
    • retry_last_ts - integer - The last time Synapse tried and failed to reach the +remote server, in ms. This is 0 if the last attempt to communicate with the +remote server was successful.
    • +
    • retry_interval - integer - How long since the last time Synapse tried to reach +the remote server before trying again, in ms. This is 0 if no further retrying occuring.
    • +
    • failure_ts - nullable integer - The first time Synapse tried and failed to reach the +remote server, in ms. This is null if communication with the remote server has never failed.
    • +
    • last_successful_stream_ordering - nullable integer - The stream ordering of the most +recent successfully-sent PDU +to this destination, or null if this information has not been tracked yet.
    • +
    +
  • +
  • next_token: string representing a positive integer - Indication for pagination. See above.
  • +
  • total - integer - Total number of destinations.
  • +
+

Destination Details API

+

This API gets the retry timing info for a specific remote server.

+

The API is:

+
GET /_synapse/admin/v1/federation/destinations/<destination>
+
+

A response body like the following is returned:

+
{
+   "destination": "matrix.org",
+   "retry_last_ts": 1557332397936,
+   "retry_interval": 3000000,
+   "failure_ts": 1557329397936,
+   "last_successful_stream_ordering": null
+}
+
+

Response

+

The response fields are the same like in the destinations array in +List of destinations response.

+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/latest/usage/administration/admin_api/index.html b/latest/usage/administration/admin_api/index.html index 44d49e73d7..5e9f17da13 100644 --- a/latest/usage/administration/admin_api/index.html +++ b/latest/usage/administration/admin_api/index.html @@ -99,7 +99,7 @@ diff --git a/latest/usage/administration/admin_api/registration_tokens.html b/latest/usage/administration/admin_api/registration_tokens.html index 74ef6f9195..d0da56c424 100644 --- a/latest/usage/administration/admin_api/registration_tokens.html +++ b/latest/usage/administration/admin_api/registration_tokens.html @@ -99,7 +99,7 @@ diff --git a/latest/usage/administration/admin_faq.html b/latest/usage/administration/admin_faq.html new file mode 100644 index 0000000000..4764fabfd0 --- /dev/null +++ b/latest/usage/administration/admin_faq.html @@ -0,0 +1,317 @@ + + + + + + Admin FAQ - Synapse + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + +
+
+ +
+ +
+ +

Admin FAQ

+

How do I become a server admin?

+

If your server already has an admin account you should use the user admin API to promote other accounts to become admins. See User Admin API

+

If you don't have any admin accounts yet you won't be able to use the admin API so you'll have to edit the database manually. Manually editing the database is generally not recommended so once you have an admin account, use the admin APIs to make further changes.

+
UPDATE users SET admin = 1 WHERE name = '@foo:bar.com';
+
+

What servers are my server talking to?

+

Run this sql query on your db:

+
SELECT * FROM destinations;
+
+

What servers are currently participating in this room?

+

Run this sql query on your db:

+
SELECT DISTINCT split_part(state_key, ':', 2)
+    FROM current_state_events AS c
+    INNER JOIN room_memberships AS m USING (room_id, event_id)
+    WHERE room_id = '!cURbafjkfsMDVwdRDQ:matrix.org' AND membership = 'join';
+
+

What users are registered on my server?

+
SELECT NAME from users;
+
+

Manually resetting passwords:

+

See https://github.com/matrix-org/synapse/blob/master/README.rst#password-reset

+

I have a problem with my server. Can I just delete my database and start again?

+

Deleting your database is unlikely to make anything better.

+

It's easy to make the mistake of thinking that you can start again from a clean slate by dropping your database, but things don't work like that in a federated network: lots of other servers have information about your server.

+

For example: other servers might think that you are in a room, your server will think that you are not, and you'll probably be unable to interact with that room in a sensible way ever again.

+

In general, there are better solutions to any problem than dropping the database. Come and seek help in https://matrix.to/#/#synapse:matrix.org.

+

There are two exceptions when it might be sensible to delete your database and start again:

+
    +
  • You have never joined any rooms which are federated with other servers. For instance, a local deployment which the outside world can't talk to.
  • +
  • You are changing the server_name in the homeserver configuration. In effect this makes your server a completely new one from the point of view of the network, so in this case it makes sense to start with a clean database. +(In both cases you probably also want to clear out the media_store.)
  • +
+

I've stuffed up access to my room, how can I delete it to free up the alias?

+

Using the following curl command:

+
curl -H 'Authorization: Bearer <access-token>' -X DELETE https://matrix.org/_matrix/client/r0/directory/room/<room-alias>
+
+

<access-token> - can be obtained in riot by looking in the riot settings, down the bottom is: +Access Token:<click to reveal>

+

<room-alias> - the room alias, eg. #my_room:matrix.org this possibly needs to be URL encoded also, for example %23my_room%3Amatrix.org

+

How can I find the lines corresponding to a given HTTP request in my homeserver log?

+

Synapse tags each log line according to the HTTP request it is processing. When it finishes processing each request, it logs a line containing the words Processed request: . For example:

+
2019-02-14 22:35:08,196 - synapse.access.http.8008 - 302 - INFO - GET-37 - ::1 - 8008 - {@richvdh:localhost} Processed request: 0.173sec/0.001sec (0.002sec, 0.000sec) (0.027sec/0.026sec/2) 687B 200 "GET /_matrix/client/r0/sync HTTP/1.1" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" [0 dbevts]"
+
+

Here we can see that the request has been tagged with GET-37. (The tag depends on the method of the HTTP request, so might start with GET-, PUT-, POST-, OPTIONS- or DELETE-.) So to find all lines corresponding to this request, we can do:

+
grep 'GET-37' homeserver.log
+
+

If you want to paste that output into a github issue or matrix room, please remember to surround it with triple-backticks (```) to make it legible (see https://help.github.com/en/articles/basic-writing-and-formatting-syntax#quoting-code).

+

What do all those fields in the 'Processed' line mean?

+

See Request log format.

+

What are the biggest rooms on my server?

+
SELECT s.canonical_alias, g.room_id, count(*) AS num_rows 
+FROM 
+  state_groups_state AS g, 
+  room_stats_state AS s 
+WHERE g.room_id = s.room_id 
+GROUP BY s.canonical_alias, g.room_id
+ORDER BY num_rows desc 
+LIMIT 10;
+
+

You can also use the List Room API +and order_by state_events.

+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/latest/usage/administration/database_maintenance_tools.html b/latest/usage/administration/database_maintenance_tools.html new file mode 100644 index 0000000000..34d59ad9d2 --- /dev/null +++ b/latest/usage/administration/database_maintenance_tools.html @@ -0,0 +1,267 @@ + + + + + + Database Maintenance Tools - Synapse + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + +
+
+ +
+ +
+ +

This blog post by Victor Berger explains how to use many of the tools listed on this page: https://levans.fr/shrink-synapse-database.html

+

List of useful tools and scripts for maintenance Synapse database:

+

Purge Remote Media API

+

The purge remote media API allows server admins to purge old cached remote media.

+

Purge Local Media API

+

This API deletes the local media from the disk of your own server.

+

Purge History API

+

The purge history API allows server admins to purge historic events from their database, reclaiming disk space.

+

synapse-compress-state

+

Tool for compressing (deduplicating) state_groups_state table.

+

SQL for analyzing Synapse PostgreSQL database stats

+

Some easy SQL that reports useful stats about your Synapse database.

+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/latest/usage/administration/index.html b/latest/usage/administration/index.html index f097377b78..a84eae1b68 100644 --- a/latest/usage/administration/index.html +++ b/latest/usage/administration/index.html @@ -99,7 +99,7 @@ diff --git a/latest/usage/administration/request_log.html b/latest/usage/administration/request_log.html index bf6b5a73f0..1992b56f90 100644 --- a/latest/usage/administration/request_log.html +++ b/latest/usage/administration/request_log.html @@ -99,7 +99,7 @@ @@ -223,13 +223,13 @@ small processing times.