Utility Functions
Utility functions for pyTigerGraph.
All functions in this module are called as methods on a TigerGraphConnection
object.
echo()
echo(usePost: bool = False) → str
Pings the database.
Parameter:
-
usePost
: Use POST instead of GET
Returns:
"Hello GSQL" if everything was OK.
Endpoint:
-
GET /echo
-
POST /echo
See Echo
getLicenseInfo()
getLicenseInfo() → dict
Returns the expiration date and remaining days of the license.
Returns:
Returns license details. For an evaluation/trial deployment, returns an information message and -1 remaining days.
ping()
ping() → dict
Public health check endpoint.
Returns:
Returns a JSON object with a key of "message" and a value of "pong"
getSystemMetrics()
getSystemMetrics(from_ts: int = None, to_ts: int = None, latest: int = None, what: str = None, who: str = None, where: str = None)
Monitor system usage metrics.
Parameters:
-
from_ts (int, optional)
: The epoch timestamp that indicates the start of the time filter. -
to_ts (int, optional)
: The epoch timestamp that indicates the end of the time filter. -
latest (int, optional)
: Number of datapoints to return. If provided,from_ts
andto_ts
will be ignored. -
what (str, optional)
: Name of the metric to filter for. Possible choices are:-
"cpu": Percentage of CPU usage by component
-
"mem": Memory usage in megabytes by component
-
"diskspace": Disk usage in megabytes by directory
-
"network": Network traffic in bytes since the service started
-
"qps": Number of requests per second by endpoint
-
"servicestate": The state of the service, either online 1 or offline 0 (Only avaliable in version <4.1)
-
"connection": Number of open TCP connections (Only avaliable in version <4.1)
-
-
who (str, optional)
: Name of the component that reported the datapoint. (Only avaliable in version <4.1) -
where (str, optional)
: Name of the node that reported the datapoint.
Returns:
JSON object of datapoints collected. Note: Output format differs between 3.x and 4.x versions of TigerGraph.
Endpoints:
-
GET /ts3/api/datapoints
(In TigerGraph versions 3.x) See xref:tigergraph-server:API:built-in-endpoints.adoc#_monitor_system_metrics_ts3_deprecated -
POST /informant/metrics/get/{metrics_category}
(In TigerGraph versions 4.x) See xref:tigergraph-server:API:built-in-endpoints.adoc#_monitor_system_metrics_by_category
getQueryPerformance()
getQueryPerformance(seconds: int = 10)
Returns real-time query performance statistics over the given time period, as specified by the seconds parameter.
Parameter:
-
seconds (int, optional)
: Seconds are measured up to 60, so the seconds parameter must be a positive integer less than or equal to 60. Defaults to 10.
getServiceStatus()
getServiceStatus(request_body: dict)
Returns the status of the TigerGraph services specified in the request. Supported on databases versions 3.4 and above.
Parameter:
-
request_body (dict)
: Must be formatted as specified here: https://docs.tigergraph.com/tigergraph-server/current/api/built-in-endpoints#_show_service_status
rebuildGraph()
rebuildGraph(threadnum: int = None, vertextype: str = "", segid: str = "", path: str = "", force: bool = False)
Rebuilds the graph engine immediately.
See this for more details. for more information.
Parameters:
threadnum (int, optional):
Number of threads to execute the rebuild.
* vertextype (str, optional)
: Vertex type to perform the rebuild for. Will perform for all vertex types if not specified.
* segid (str, optional)
: Segment ID of the segments to rebuild. If not provided, all segments will be rebuilt.
In general, it is recommneded not to provide this parameter and rebuild all segments.
* path (str, optional)
: Path to save the summary of the rebuild to. If not provided, the default path is "/tmp/rebuildnow".
* force (bool, optional)
: Boolean value that indicates whether to perform rebuilds for segments for which there are no records of new data.
Normally, a rebuild would skip such segments, but if force is set true, the segments will not be skipped.
Returns:
JSON response with message containing the path to the summary file.