This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
gohandlers "github.com/gorilla/handlers" | |
"github.com/gorilla/mux" | |
"github.com/hashicorp/go-hclog" | |
"go.mongodb.org/mongo-driver/bson" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"connPoolCreated": 1, | |
"connSuccess": 2, | |
"connClosed": 0, | |
"connReturned": 2, | |
"connPoolCleared": 0, | |
"serverHeartbeatStart": [{ | |
"ConnectionID": "localhost:27017[-2]", | |
"Awaited": true | |
}, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"connPoolCreated": 1, | |
"connSuccess": 2, | |
"connClosed": 0, | |
"connReturned": 2, | |
"connPoolCleared": 3, | |
"serverHeartbeatStart": [{ | |
"ConnectionID": "localhost:27017[-3]", | |
"Awaited": true | |
}, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
poolMonitor := &event.PoolMonitor{ | |
Event: func(e *event.PoolEvent) { | |
switch e.Type { | |
case event.PoolCreated: | |
// mongo-connection pool creation events. | |
connPoolCreated++ | |
case event.GetSucceeded: | |
// succesful mongo connection established by the pool | |
connSuccess++ | |
case event.ConnectionClosed: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmdMonitor := &event.CommandMonitor{ | |
Started: func(_ context.Context, evt *event.CommandStartedEvent) { | |
// Command Started event triggered when a mongo query transaction prepares the command lifecycle for | |
// certain DatabaseName | |
CommandStartedEvent { | |
Command bson.Raw // base64 hash value of the mongo query transaction raw | |
DatabaseName string // mongodb database name | |
CommandName string // mongodb query name [ping,insert,update,find] | |
RequestID int64 // mongo query command unique ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
serverMonitor := &event.ServerMonitor{ | |
ServerHeartbeatStarted: func(evt *event.ServerHeartbeatStartedEvent) { | |
// Started event triggered when connection heartbeat prepares to start the connection lifecycle | |
// in the mongo cluster | |
ServerHeartbeatStartedEvent struct { | |
ConnectionID string // mongo connection ids [host-ids] | |
Awaited bool // If the connection is awaiting | |
} |
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 6 columns, instead of 2. in line 4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_id,comment,date,email,movie_id,name | |
5a9427648b0beebeb69579cc,Rem officiis eaque repellendus amet eos doloribus. Porro dolor voluptatum voluptates neque culpa molestias. Voluptate unde nulla temporibus ullam.,2012-03-26T00:00:00.000Z,andrea_le@fakegmail.com,573a1390f29313caabcd6223,Andrea Le | |
5a9427648b0beebeb6957a87,Reiciendis adipisci veritatis molestias sint officiis ab cupiditate. Reiciendis laudantium nam explicabo rerum. Ea accusamus iste necessitatibus.,1979-12-27T00:00:00.000Z,anthony_cline@fakegmail.com,573a1390f29313caabcd6224,Anthony Cline | |
5a9427648b0beebeb6957ac9,Accusantium dolore cupiditate saepe iure. Deleniti accusantium voluptatibus vel eligendi nostrum enim incidunt doloribus. Similique laboriosam deleniti blanditiis.,1983-03-11T00:00:00.000Z,emily_ellis@fakegmail.com,573a1390f29313caabcd6225,Emily Ellis | |
5a9427648b0beebeb6957ad0,Facere esse ducimus animi pariatur ullam ab a est. Tempora odit vero tenetur impedit iure rem. Dicta beatae qui alias. Nihil quibusdam nihil vitae quidem doloribus de |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_id | title | year | genres.0 | genres.1 | genres.2 | imdb.votes | imdb.rating | released_date | |
---|---|---|---|---|---|---|---|---|---|
573a1390f29313caabcd6223 | In Old Arizona | 1928 | Comedy | Western | 576 | 5.8 | 1929-01-20 | ||
573a1390f29313caabcd6224 | The Public Enemy | 1931 | Crime | Drama | 12384 | 7.8 | 1931-04-23 | ||
573a1390f29313caabcd6225 | High and Dizzy | 1920 | Comedy | Short | 646 | 7 | 1920-07-11 | ||
573a1390f29313caabcd6226 | Nanook of the North | 1922 | Documentary | 6918 | 7.8 | 1922-06-11 | |||
573a1390f29313caabcd6227 | Battleship Potemkin | 1925 | History | War | 36901 | 8 | 1925-12-24 | ||
573a1390f29313caabcd6228 | The Gold Rush | 1925 | Adventure | Comedy | Drama | 59483 | 8.3 | 1925-07-18 | |
573a1390f29313caabcd6229 | For Heaven's Sake | 1926 | Action | Comedy | 918 | 7.6 | 1926-04-05 | ||
573a1390f29313caabcd6213 | The Cameraman | 1928 | Comedy | Family | 6886 | 8.3 | 1928-09-22 | ||
573a1390f29313caabcd6263 | The Circus | 1928 | Comedy | 16017 | 8.1 | 1928-05-02 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id": ObjectId("573a1391f29313caabcd8b94"), | |
"title": "The Last Command", | |
"plot": "A former Imperial Russian general and cousin of the Czar ends up in Hollywood as an | |
extra in a movie directed by a former revolutionary.", | |
"rated": "GOOD", | |
"language": "Russian", | |
"year": 1928, | |
"poster": "https://m.media-amazon.com/images/M/MV5BMTg2Mjg3MDI5OF5BMl5BanBnXkFtZTgwMjMzMDMyMjE@._V1_SY1000_SX677_AL_.jpg", | |
"director": "Josef von Sternberg", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.project_data.aggregate([ | |
{ | |
$project: { | |
"_id": 0, | |
"title": 1, | |
"plot": 1, | |
"year": 1, | |
"language": 1, | |
"rated": 1, | |
"poster": 1, |
NewerOlder