How do I query a collection or index using REST/http in an embedded RavenDB v3.5?

Firstly I feel like the need to qualify why having to do this on such an old version of RavenDB:

We are using Particular ServiceControl for NServiceBus/RabbitMQ message handling, namely error messages. Latest version of ServiceControl (v4.22.0) uses an embedded RavenDB v3.5 for storing among other things failed messages.

We need to monitor these failed messages using an external monitoring tool, and therefore I need to periodically scrape and group the failed messages and expose these groupings as metrics for the monitoring software to react upon.

Attempts so far

I have managed to expose the RavenDB database thus allowing myself to access it via REST/http. As such I can loop through e.g. an index using a request like

curl -X GET "http://localhost:33334/indexes/FailedMessageViewIndex?pageSize=5"

This works, but have no filtering options, field selectors or the like.

According to docs (of later versions, I admit), I should be able to query indices like this with RQL syntax:

curl -X POST "http://live-test.ravendb.net/databases/<system>/queries" -d "{ \"Query\": \"from doc in docs.FailedMessages\" }"

but I can only get it to produce the following error:

{"Url":"/databases/%3Csystem%3E/queries?debug=true","Error":"System.Exception: Error reading RavenJArray from JsonReader. Current JsonReader item is not an array: StartObject\r\n at Raven.Json.Linq.RavenJArray.Load(JsonReader reader)\r\n at Raven.Database.Server.Controllers.RavenBaseApiController.d__28.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Raven.Database.Server.Controllers.QueriesController.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.d__1`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.d__6.MoveNext()"}

Now I can deduce that this /queries endpoint expects an array of some sort, but poking around Raven Studio this seems to be a fixed list of strings with which to obtain various information, e.g. payloads ["Raven/StudioConfig"], ["Raven/Alerts"] et.al.

Lastly I can seem to touch something by using the GET request I started out with with a "query" query string parameter, but I get no results - i.e.

curl -X GET http://localhost:33334/indexes/FailedMessageViewIndex?pageSize=3&query=from%20index%20FailedMessageViewIndex

Result:

{ "Results": [], "Includes": [], "IsStale": false, "IndexTimestamp": "2022-10-11T23:01:30.7137228Z", "TotalResults": 0, "SkippedResults": 0, "IndexName": "FailedMessageViewIndex", "IndexEtag": "01000000-0000-0101-0000-00000000DE8D", "ResultEtag": "6F5C0902-5EAA-79A4-9D23-B493D5048FB6", "Highlightings": {}, "NonAuthoritativeInformation": false, "LastQueryTime": "2022-10-11T23:01:31.6916452Z", "DurationMilliseconds": 0, "ScoreExplanations": {}, "TimingsInMilliseconds": {}, "ResultSize": 0 }

The question

I realize that I am at this point merely trying to guess my way through.

But my question is: can I somehow query my embedded RavenDB v3.5 with REST/http using RQL, Lucene or in some other way provide arguments as to what I wish to retrieve?

Upvotes: 2

Views: 45

Answers (0)

Related Questions