Skip to content

Commit bf42c24

Browse files
committed
2 parents aeb25d5 + dd013cd commit bf42c24

File tree

165 files changed

+674
-941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+674
-941
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
.vscode/settings.json
55
.vscode/
66
.idea
7-
venv
7+
venv
8+
.venv

.readthedocs.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ python:
1212
- requirements: ./requirements_docs.txt
1313

1414
sphinx:
15-
configuration: ./conf.py
15+
configuration: ./conf.py
16+
17+
formats:
18+
- epub
19+
- pdf

admin/mgmt_commands/index.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ This will produce output that looks like the following
266266
267267
DJANGO_SETTINGS_MODULE=geonode.settings python manage.py sync_geonode_maps --updatethumbnails -f 'This is a test Map'
268268
269-
Management Command ``set_all_layers_metadata``
269+
Management Command ``set_all_datasets_metadata``
270270
----------------------------------------------
271271
272272
This command allows to reset **Metadata Attributes** and **Catalogue Schema** on Datasets. The command will also update the :guilabel:`CSW Catalogue` XML and Links of GeoNode.
@@ -287,26 +287,26 @@ The options are:
287287
*
288288
* **set_links**; If set will refresh the links of the resource. (Default True).
289289
290-
First of all let's take a look at the :guilabel:`--help` option of the ``set_all_layers_metadata``
290+
First of all let's take a look at the :guilabel:`--help` option of the ``set_all_datasets_metadata``
291291
management command in order to inspect all the command options and features.
292292

293293
Run
294294

295295
.. code-block:: shell
296296
297-
DJANGO_SETTINGS_MODULE=geonode.settings python manage.py set_all_layers_metadata --help
297+
DJANGO_SETTINGS_MODULE=geonode.settings python manage.py set_all_datasets_metadata --help
298298
299299
.. note:: If you enabled ``local_settings.py`` the command will change as following:
300300

301301
.. code-block:: shell
302302
303-
DJANGO_SETTINGS_MODULE=geonode.local_settings python manage.py set_all_layers_metadata --help
303+
DJANGO_SETTINGS_MODULE=geonode.local_settings python manage.py set_all_datasets_metadata --help
304304
305305
This will produce output that looks like the following
306306

307307
.. code-block:: shell
308308
309-
usage: manage.py set_all_layers_metadata [-h] [--version] [-v {0,1,2,3}]
309+
usage: manage.py set_all_datasets_metadata [-h] [--version] [-v {0,1,2,3}]
310310
[--settings SETTINGS]
311311
[--pythonpath PYTHONPATH]
312312
[--traceback] [--no-color] [-i] [-d]
@@ -346,7 +346,7 @@ This will produce output that looks like the following
346346
347347
.. code-block:: shell
348348
349-
DJANGO_SETTINGS_MODULE=geonode.settings python manage.py set_all_layers_metadata -d
349+
DJANGO_SETTINGS_MODULE=geonode.settings python manage.py set_all_datasets_metadata -d
350350
351351
.. _load_data_into_geonode:
352352

advanced/components/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ What we will see in this section is:
1010

1111
* **GeoNode** (Security Backend):
1212

13-
#. DJango Authentication
13+
#. Django Authentication
1414

15-
#. DJango OAuth Toolkit Setup and Configuration
15+
#. Django OAuth Toolkit Setup and Configuration
1616

1717
#. Details on ``settings.py`` Security Settings
1818

advanced/contrib/index.rst

Lines changed: 0 additions & 301 deletions
Original file line numberDiff line numberDiff line change
@@ -305,304 +305,3 @@ and the ``/opt/geonode/my-geonode/.env`` is something similar to the following o
305305
vacuum = true
306306
thunder-lock = true
307307
308-
.. _centralized-monitoring:
309-
310-
Geonode Logstash for centralized monitoring/analytics
311-
=====================================================
312-
313-
This contrib app, along with the GeoNode internal monitoring app, lets administrators
314-
to configure a service for sending metrics data to a **centralized server**
315-
which comes with `Logstash <https://www.elastic.co/products/logstash>`_.
316-
317-
So it will be possible to visualize stats and charts about one or more GeoNode instances outside the application.
318-
Having a server configured with the `ELK stack <https://www.elastic.co/what-is/elk-stack>`_,
319-
it is possible to visualize those information on a Kibana dashboard for example.
320-
321-
If you manage more than one GeoNode instances, that server can receive data from
322-
many GeoNode(s) so it can make available both *single-instance dashboards*
323-
(referred to individual instances) and *global dashboards*
324-
(stats calculated on the whole set of instances).
325-
326-
.. warning:: The centralized monitoring service cannot be active if the settings variables :ref:`user-analytics` and :ref:`monitoring-enabled` are set to `False`.
327-
328-
Overview
329-
--------
330-
331-
By default, GeoNode will send data to the centralized server every **3600 seconds**
332-
(1 hour) so, if enabled, the monitoring app will collect 1-hour-aggregated data.
333-
This time interval can be configured, see the next paragraphs to know how.
334-
335-
Formatted and compressed data will be sent on a **TCP** connection (on the `443` standard port by default)
336-
through a **scheduled celery task** which basically logs information
337-
via `python-logstash-async <https://pypi.org/project/python-logstash-async/>`_.
338-
339-
.. warning:: This feature requires `python-logstash-async <https://pypi.org/project/python-logstash-async/>`_.
340-
341-
.. _events-formats:
342-
343-
Data and events formats
344-
~~~~~~~~~~~~~~~~~~~~~~~
345-
346-
Each time the centralized monitoring service is called, 4 types of *JSON* formatted events are sent to the server:
347-
348-
1. Instance overview
349-
350-
.. code-block:: json
351-
352-
{
353-
"format_version": "1.0",
354-
"instance": {
355-
"name": geonode instance HOSTNAME,
356-
"ip": geonode instance IP
357-
},
358-
"time": {
359-
"startTime": UTC now - 1 hour (default)
360-
"endTime": UTC now
361-
},
362-
"hits": total number of requests,
363-
"unique_visits": total number of unique sessions,
364-
"unique_visitors": total number of unique users,
365-
"registered_users": total number of registered users at the end time,
366-
"layers": total number of layers at the end time,
367-
"documents": total number of documents at the end time,
368-
"maps": total number of maps at the end time,
369-
"errors": total number of errors
370-
}
371-
372-
2. Resources details
373-
374-
.. code-block:: json
375-
376-
{
377-
"format_version": "1.0",
378-
"instance": {
379-
"name": geonode instance HOSTNAME,
380-
"ip": geonode instance IP
381-
},
382-
"time": {
383-
"startTime": UTC now - 1 hour (default)
384-
"endTime": UTC now
385-
},
386-
"resources": [
387-
388-
{
389-
"type": resource type,
390-
"name": resource name,
391-
"url": resource URL,
392-
"hits": total number of requests about this resource,
393-
"unique_visits": total number of unique sessions about this resource,
394-
"unique_visitors": total number of unique users about this resource,
395-
"downloads": total number of resource downloads,
396-
"ogcHits": total number of OGC service requests about this resource,
397-
"publications": total number of publication events
398-
},
399-
400-
]
401-
}
402-
403-
3. Countries details
404-
405-
.. code-block:: json
406-
407-
{
408-
"format_version": "1.0",
409-
"instance": {
410-
"name": geonode instance HOSTNAME,
411-
"ip": geonode instance IP
412-
},
413-
"time": {
414-
"startTime": UTC now - 1 hour (default)
415-
"endTime": UTC now
416-
},
417-
"countries": [
418-
419-
{
420-
"name": country name,
421-
"hits": total number of requests about the country
422-
},
423-
424-
]
425-
}
426-
427-
4. UA (User Agent) Family details
428-
429-
.. code-block:: json
430-
431-
{
432-
"format_version": "1.0",
433-
"instance": {
434-
"name": geonode instance HOSTNAME,
435-
"ip": geonode instance IP
436-
},
437-
"time": {
438-
"startTime": UTC now - 1 day
439-
"endTime": UTC now
440-
},
441-
"ua_families": [
442-
443-
{
444-
"name": UA family name
445-
"hits": total number of requests about the UA family
446-
},
447-
448-
]
449-
}
450-
451-
These messages will be `gzip <https://docs.python.org/2/library/zlib.html>`_
452-
compressed in order to improve transport performances and they should be parsed
453-
by a `logstash filter <https://www.elastic.co/guide/en/logstash/current/plugins-codecs-gzip_lines.html>`_
454-
on the server side (see :ref:`logstash-input`).
455-
456-
Configuration
457-
-------------
458-
459-
The centralized monitoring service is disabled by default because it needs
460-
the internal monitoring to be active and service-specific configurations.
461-
462-
GeoNode configuration
463-
~~~~~~~~~~~~~~~~~~~~~
464-
465-
| On the GeoNode side, all needed configurations can be set up from the Django admin interface.
466-
| If enabled, the **GEONODE LOGSTASH** section will show the **Centralized servers** feature:
467-
468-
.. image:: img/centralized_server_admin_ui.png
469-
:alt: Centralized Servers from admin UI
470-
471-
Let's add one:
472-
473-
.. image:: img/add_centralized_server.png
474-
:alt: Centralized Server set up
475-
476-
The **Host** IP address and the **Port** number are mandatory as well as the
477-
time **Interval** (3600 seconds by default) which defines the service
478-
invocation polling (so the time range on which data should be aggregated).
479-
480-
.. note:: Once the service configured, the user can test the configuration by clicking on **Test connection**.
481-
It will test the connection with the centralized server without saving the configuration.
482-
483-
Other settings come with a default value:
484-
485-
* **Db path** --> the local Spatialite database to cache events between emitting and transmission to the Logstash server (log events are cached even across process restarts and crashes);
486-
* **Socket timeout** --> timeout in seconds for TCP connections;
487-
* **Queue check interval** --> interval in seconds to check the internal queue for new messages to be cached in the database;
488-
* **Queue events flush interval** --> interval in seconds to send cached events from the database to Logstash;
489-
* **Queue events flush count** --> count of cached events to send from the database to Logstash;
490-
* **Queue events batch size** --> maximum number of events to be sent to Logstash in one batch;
491-
* **Logstash db timeout** --> timeout in seconds to 'connect' the Spatialite database.
492-
493-
To better understand what these variables mean, it is recommended to read the `python-logstash-async options for the asynchronous processing and formatting <https://python-logstash-async.readthedocs.io/en/stable/config.html#options-for-the-asynchronous-processing-and-formatting>`_.
494-
495-
Other three read-only fields will be visible:
496-
497-
* **Last successful deliver** --> timestamp of the last successful deliver (if exists);
498-
* **Next scheduled deliver** --> timestamp of the next scheduled deliver;
499-
* **Last failed deliver** --> timestamp of the last failed deliver (if exists).
500-
501-
.. _logstash-input:
502-
503-
Logstash configuration
504-
~~~~~~~~~~~~~~~~~~~~~~
505-
506-
| On the server side, a proper Logstash configuration should be set up.
507-
| Some events formats contain arrays (see :ref:`events-formats`) so Logstash should
508-
be able to retrieve a single event for each element of the array.
509-
The `Split filter plugin <https://www.elastic.co/guide/en/logstash/current/plugins-filters-split.html#plugins-filters-split>`_
510-
helps to correctly parse those messages.
511-
| As mentioned above, events messages will be gzip compressed so the
512-
`Gzip_lines codec plugin <https://www.elastic.co/guide/en/logstash/current/plugins-codecs-gzip_lines.html#plugins-codecs-gzip_lines>`_
513-
should be installed along with Logstash and the "gzip_lines" codec should be used for the `tcp` input.
514-
515-
An example of the logstash configuration:
516-
517-
.. code-block:: json
518-
519-
input {
520-
tcp {
521-
port => <logstash_port_number>
522-
codec => "gzip_lines"
523-
}
524-
}
525-
526-
filter {
527-
json {
528-
source => "message"
529-
}
530-
if [format_version] == "1.0" {
531-
if [countries] {
532-
split {
533-
field => "countries"
534-
}
535-
}
536-
if [resources] {
537-
split {
538-
field => "resources"
539-
}
540-
}
541-
if [ua_families] {
542-
split {
543-
field => "ua_families"
544-
}
545-
}
546-
mutate {
547-
remove_field => "message"
548-
}
549-
}
550-
geoip {
551-
source => "[instance][ip]"
552-
}
553-
}
554-
555-
output {
556-
elasticsearch {
557-
hosts => "elasticsearch:<elastic_port_number>"
558-
index => "logstash-%{[instance][name]}-%{+YYYY.MM.dd}"
559-
user => "elastic"
560-
password => "changeme"
561-
}
562-
stdout { codec => rubydebug }
563-
}
564-
565-
Usage
566-
-----
567-
568-
When saving the service configuration, if monitoring enabled, GeoNode will create/update a celery
569-
`Periodic Task <https://docs.celeryproject.org/en/v4.2.1/userguide/periodic-tasks.html#periodic-tasks>`_
570-
which will be executed at regular intervals based on the *interval* configured.
571-
572-
You can check this behavior on the *Periodic Tasks* section of the admin UI:
573-
574-
.. image:: img/periodic_tasks_section.png
575-
:alt: Periodic tasks section
576-
577-
The *dispatch-metrics-task* task:
578-
579-
.. image:: img/dispatch_metrics_task.png
580-
:alt: Dispatch metrics task
581-
582-
The task details:
583-
584-
.. image:: img/dispatch_metrics_task_details.png
585-
:alt: Dispatch metrics task details
586-
587-
.. warning:: When disabling monitoring is a **good practice** to disable the corresponding Periodic Task too.
588-
589-
Management command
590-
~~~~~~~~~~~~~~~~~~
591-
592-
| In addition to the scheduled task, this contrib app makes also available the
593-
**dispatch_metrics** command to manually send metrics to the server.
594-
| Obviously the time interval considered will start at the last successful
595-
delivery and will finish at the current time.
596-
597-
When the monitoring plugin is enabled (:ref:`user-analytics` and :ref:`monitoring-enabled` are set to `True`)
598-
and a :ref:`centralized-monitoring` configured, Geonode sends (hourly by default) metrics data
599-
to an external server (which comes with Logstash) for stats visualization and analysis.
600-
601-
The command can be launched using the ``manage.py`` script.
602-
No options are required.
603-
604-
.. code-block:: shell
605-
606-
$ DJANGO_SETTINGS_MODULE=<your_settings_module> python manage.py dispatch_metrics
607-
608-
Possible exceptions raised during the execution will be reported to GeoNode log.

advanced/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ GeoNode Django Contrib Apps
3333
:maxdepth: 3
3434

3535
contrib/index
36+

0 commit comments

Comments
 (0)